diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-08-07 21:44:21 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-08-08 01:11:02 +0300 |
commit | e9a4602eb023d1db4c5a7b46b654a70e17fe022d (patch) | |
tree | 935d8eb12627758e1653ada82e89209d81bdde7a /internal/auth/auth.go | |
parent | dc2500d0a6e06b3e762902996867d70246173523 (diff) |
fix: propagate context to sub requests
Diffstat (limited to 'internal/auth/auth.go')
-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 7307d668..877d5163 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 @@ -494,7 +494,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) |