Skip to content

Commit

Permalink
fix(authorization): Change requester to OPA to use new context API
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyno-zeta committed Jan 20, 2021
1 parent 3d6a350 commit 6aa6a2b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/s3-proxy/authx/authorization/opa-server.go
Expand Up @@ -82,7 +82,15 @@ func isOPAServerAuthorized(req *http.Request, oidcUser *models.OIDCUser, resourc
}

// Making request to OPA server
resp, err := http.Post(resource.OIDC.AuthorizationOPAServer.URL, "application/json", bytes.NewBuffer(bb))
// Change NewRequest to NewRequestWithContext and pass context it
request, err := http.NewRequestWithContext(req.Context(), http.MethodPost, resource.OIDC.AuthorizationOPAServer.URL, bytes.NewBuffer(bb))
if err != nil {
return false, err
}
// Add content type
request.Header.Add("Content-Type", "application/json")
// Making request to OPA server
resp, err := http.DefaultClient.Do(request)
if err != nil {
return false, err
}
Expand Down

0 comments on commit 6aa6a2b

Please sign in to comment.