diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-10 06:23:16 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-10 06:23:16 +0300 |
commit | fb8ad8e35513b6b2ca230f9f814ae06ec19ae806 (patch) | |
tree | 2c950a1fbefea7e69ff01257aa66dc9f551ba2bc /internal/auth | |
parent | 029392ffad5c5533cdc916422b88711e31be1bfe (diff) | |
parent | dc6802f43525dc5308c0efa4b2ceb0bbfd6368c3 (diff) |
Merge branch 'fix/no-ctx' into 'master'
fix: propagate context to sub requests
See merge request gitlab-org/gitlab-pages!538
Diffstat (limited to 'internal/auth')
-rw-r--r-- | internal/auth/auth.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go index d4298702..29aaa582 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -185,7 +185,7 @@ func (a *Auth) checkAuthenticationResponse(session *sessions.Session, w http.Res } // Fetch access token with authorization code - token, err := a.fetchAccessToken(decryptedCode) + token, err := a.fetchAccessToken(r.Context(), decryptedCode) if err != nil { // Fetching token not OK logRequest(r).WithError(err).WithField( @@ -374,13 +374,13 @@ func verifyCodeAndStateGiven(r *http.Request) bool { return r.URL.Query().Get("code") != "" && r.URL.Query().Get("state") != "" } -func (a *Auth) fetchAccessToken(code string) (tokenResponse, error) { +func (a *Auth) fetchAccessToken(ctx context.Context, code string) (tokenResponse, error) { token := tokenResponse{} // Prepare request url := fmt.Sprintf(tokenURLTemplate, a.internalGitlabServer) content := fmt.Sprintf(tokenContentTemplate, a.clientID, a.clientSecret, code, a.redirectURI) - req, err := http.NewRequest("POST", url, strings.NewReader(content)) + req, err := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(content)) if err != nil { return token, err @@ -495,7 +495,7 @@ func (a *Auth) checkAuthentication(w http.ResponseWriter, r *http.Request, domai } else { url = fmt.Sprintf(apiURLUserTemplate, a.internalGitlabServer) } - req, err := http.NewRequest("GET", url, nil) + req, err := http.NewRequestWithContext(r.Context(), "GET", url, nil) if err != nil { logRequest(r).WithError(err).Error(failAuthErrMsg) |