Skip to content

Commit 875edcf

Browse files
authored
adding proxy from environment and tls config to token request for TMC SM (#608)
adding proxy from environment and tls config to token request Signed-off-by: warroyo <warroyo7199008@gmail.com>
1 parent 9085af1 commit 875edcf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/authctx/selfmanaged.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,17 @@ func getSMUserAuthCtx(pinnipedURL, uName, password string, config *proxy.TLSConf
9696
return nil, fmt.Errorf("login failed with code %q: %s", requiredErrorCode, optionalErrorDescription)
9797
}
9898

99+
customClient := &http.Client{
100+
Transport: &http.Transport{
101+
TLSClientConfig: tlsConfig,
102+
Proxy: http.ProxyFromEnvironment,
103+
},
104+
}
99105
// Exchange the authorization code for access, ID, and refresh tokens and perform required
100106
// validations on the returned ID token.
101-
tokenCtx, tokenCtxCancelFunc := context.WithTimeout(context.Background(), contextTimeout)
107+
ctxWithValue := context.WithValue(context.Background(), oauth2.HTTPClient, customClient)
102108

109+
tokenCtx, tokenCtxCancelFunc := context.WithTimeout(ctxWithValue, contextTimeout)
103110
defer tokenCtxCancelFunc()
104111

105112
token, err := session.sharedOauthConfig.Exchange(tokenCtx, authCode, session.pkceCodePair.Verifier())
@@ -204,6 +211,7 @@ func (s *smSession) initiateAuthorizeRequestUnamePwd() (*url.URL, error) {
204211
httpClient := &http.Client{
205212
Transport: &http.Transport{
206213
TLSClientConfig: s.tlsConfig,
214+
Proxy: http.ProxyFromEnvironment,
207215
},
208216
CheckRedirect: func(r *http.Request, via []*http.Request) error {
209217
redirected = true

0 commit comments

Comments
 (0)