@@ -91,9 +91,10 @@ type Provider struct {
9191 // often available via site-specific packages, such as
9292 // google.Endpoint or github.Endpoint.
9393 // - 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
9798}
9899
99100// 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
103104// NewOauth2ProviderClient instantiates a new oauth2 client using the configured credentials
104105// it returns a *Provider object that contains the necessary configuration to initiate an
105106// 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 ())
108110 if err != nil {
109111 return nil , err
110112 }
@@ -122,6 +124,7 @@ func NewOauth2ProviderClient(ctx context.Context, scopes []string) (*Provider, e
122124 }
123125 client .oidcProvider = provider
124126 client .ClientID = GetIdpClientID ()
127+ client .provHTTPClient = httpClient
125128
126129 return client , nil
127130}
@@ -172,10 +175,11 @@ func (client *Provider) VerifyIdentity(ctx context.Context, code, state string)
172175 }, nil
173176 }
174177 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+ })
179183 return sts , nil
180184}
181185
0 commit comments