@@ -91,9 +91,10 @@ type Provider struct {
91
91
// often available via site-specific packages, such as
92
92
// google.Endpoint or github.Endpoint.
93
93
// - Scopes specifies optional requested permissions.
94
- ClientID string
95
- oauth2Config Configuration
96
- oidcProvider * oidc.Provider
94
+ ClientID string
95
+ oauth2Config Configuration
96
+ oidcProvider * oidc.Provider
97
+ provHTTPClient * http.Client
97
98
}
98
99
99
100
// derivedKey is the key used to compute the HMAC for signing the oauth state parameter
@@ -103,8 +104,9 @@ var derivedKey = pbkdf2.Key([]byte(getPassphraseForIdpHmac()), []byte(getSaltFor
103
104
// NewOauth2ProviderClient instantiates a new oauth2 client using the configured credentials
104
105
// it returns a *Provider object that contains the necessary configuration to initiate an
105
106
// oauth2 authentication flow
106
- func NewOauth2ProviderClient (ctx context.Context , scopes []string ) (* Provider , error ) {
107
- provider , err := oidc .NewProvider (ctx , GetIdpURL ())
107
+ func NewOauth2ProviderClient (ctx context.Context , scopes []string , httpClient * http.Client ) (* Provider , error ) {
108
+ customCtx := oidc .ClientContext (ctx , httpClient )
109
+ provider , err := oidc .NewProvider (customCtx , GetIdpURL ())
108
110
if err != nil {
109
111
return nil , err
110
112
}
@@ -122,6 +124,7 @@ func NewOauth2ProviderClient(ctx context.Context, scopes []string) (*Provider, e
122
124
}
123
125
client .oidcProvider = provider
124
126
client .ClientID = GetIdpClientID ()
127
+ client .provHTTPClient = httpClient
125
128
126
129
return client , nil
127
130
}
@@ -172,10 +175,11 @@ func (client *Provider) VerifyIdentity(ctx context.Context, code, state string)
172
175
}, nil
173
176
}
174
177
stsEndpoint := GetSTSEndpoint ()
175
- sts , err := credentials .NewSTSWebIdentity (stsEndpoint , getWebTokenExpiry )
176
- if err != nil {
177
- return nil , err
178
- }
178
+ sts := credentials .New (& credentials.STSWebIdentity {
179
+ Client : client .provHTTPClient ,
180
+ STSEndpoint : stsEndpoint ,
181
+ GetWebIDTokenExpiry : getWebTokenExpiry ,
182
+ })
179
183
return sts , nil
180
184
}
181
185
0 commit comments