From 9ca72fcd30165d244c6bf707f3f358c5b741fc26 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Wed, 12 May 2021 12:57:10 -0700 Subject: [PATCH] login.go: Respect `overallTimeout` for LDAP login-related http requests Signed-off-by: Matt Moyer --- pkg/oidcclient/login.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/oidcclient/login.go b/pkg/oidcclient/login.go index 9908b792..d8539090 100644 --- a/pkg/oidcclient/login.go +++ b/pkg/oidcclient/login.go @@ -404,7 +404,7 @@ func (h *handlerState) cliBasedAuth(authorizeOptions *[]oauth2.AuthCodeOption) ( } // Send an authorize request. - authCtx, authorizeCtxCancelFunc := context.WithTimeout(context.Background(), httpRequestTimeout) + authCtx, authorizeCtxCancelFunc := context.WithTimeout(h.ctx, httpRequestTimeout) defer authorizeCtxCancelFunc() authReq, err := http.NewRequestWithContext(authCtx, http.MethodGet, authorizeURL, nil) if err != nil { @@ -454,7 +454,7 @@ func (h *handlerState) cliBasedAuth(authorizeOptions *[]oauth2.AuthCodeOption) ( // Exchange the authorization code for access, ID, and refresh tokens and perform required // validations on the returned ID token. - tokenCtx, tokenCtxCancelFunc := context.WithTimeout(context.Background(), httpRequestTimeout) + tokenCtx, tokenCtxCancelFunc := context.WithTimeout(h.ctx, httpRequestTimeout) defer tokenCtxCancelFunc() token, err := h.getProvider(h.oauth2Config, h.provider, h.httpClient). ExchangeAuthcodeAndValidateTokens(