Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pass context through to external requests #627

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pipeline/authn/authenticator_cookie_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ func forwardRequestToSessionStore(r *http.Request, checkSessionURL string, prese
reqUrl.Path = r.URL.Path
}

res, err := http.DefaultClient.Do(&http.Request{
req := http.Request{
Method: r.Method,
URL: reqUrl,
Header: r.Header,
})
}
res, err := http.DefaultClient.Do(req.WithContext(r.Context()))
if err != nil {
return nil, helper.ErrForbidden.WithReason(err.Error()).WithTrace(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (a *AuthenticatorOAuth2ClientCredentials) Authenticate(r *http.Request, ses
}

token, err := c.Token(context.WithValue(
context.Background(),
r.Context(),
oauth2.HTTPClient,
c.Client,
))
Expand Down
2 changes: 1 addition & 1 deletion pipeline/authn/authenticator_oauth2_introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (a *AuthenticatorOAuth2Introspection) Authenticate(r *http.Request, session
}
// set/override the content-type header
introspectReq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := a.client.Do(introspectReq)
resp, err := a.client.Do(introspectReq.WithContext(r.Context()))
if err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/authz/keto_engine_acp_ory.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (a *AuthorizerKetoEngineACPORY) Authorize(r *http.Request, session *authn.A
}
req.Header.Add("Content-Type", "application/json")

res, err := a.client.Do(req)
res, err := a.client.Do(req.WithContext(r.Context()))
if err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/authz/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (a *AuthorizerRemote) Authorize(r *http.Request, session *authn.Authenticat
req.Header.Set(hdr, headerValue.String())
}

res, err := a.client.Do(req)
res, err := a.client.Do(req.WithContext(r.Context()))
if err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/authz/remote_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (a *AuthorizerRemoteJSON) Authorize(r *http.Request, session *authn.Authent
req.Header.Add("Authorization", authz)
}

res, err := a.client.Do(req)
res, err := a.client.Do(req.WithContext(r.Context()))
if err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/mutate/mutator_hydrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (a *MutatorHydrator) Mutate(r *http.Request, session *authn.AuthenticationS
client.Transport = httpx.NewResilientRoundTripper(a.client.Transport, maxRetryDelay, giveUpAfter)
}

res, err := client.Do(req)
res, err := client.Do(req.WithContext(r.Context()))
if err != nil {
return errors.WithStack(err)
}
Expand Down