You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-06-17 00:17:40 +02:00
Support context in providers (#519)
Co-authored-by: Henry Jenkins <henry@henryjenkins.name>
This commit is contained in:
committed by
Henry Jenkins
parent
53d8e99f05
commit
e642daef4e
@ -1,6 +1,7 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -46,7 +47,7 @@ func stripParam(param, endpoint string) string {
|
||||
}
|
||||
|
||||
// validateToken returns true if token is valid
|
||||
func validateToken(p Provider, accessToken string, header http.Header) bool {
|
||||
func validateToken(ctx context.Context, p Provider, accessToken string, header http.Header) bool {
|
||||
if accessToken == "" || p.Data().ValidateURL == nil || p.Data().ValidateURL.String() == "" {
|
||||
return false
|
||||
}
|
||||
@ -55,7 +56,7 @@ func validateToken(p Provider, accessToken string, header http.Header) bool {
|
||||
params := url.Values{"access_token": {accessToken}}
|
||||
endpoint = endpoint + "?" + params.Encode()
|
||||
}
|
||||
resp, err := requests.RequestUnparsedResponse(endpoint, header)
|
||||
resp, err := requests.RequestUnparsedResponse(ctx, endpoint, header)
|
||||
if err != nil {
|
||||
logger.Printf("GET %s", stripToken(endpoint))
|
||||
logger.Printf("token validation request failed: %s", err)
|
||||
|
Reference in New Issue
Block a user