1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2024-12-12 11:15:02 +02:00
oauth2-proxy/providers/auth_test.go

24 lines
566 B
Go
Raw Normal View History

2020-01-22 12:57:00 +02:00
package providers
import (
"fmt"
"net/http"
"net/url"
2020-03-29 15:54:36 +02:00
"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/sessions"
2020-01-22 12:57:00 +02:00
)
var authorizedAccessToken = "imaginary_access_token"
func CreateAuthorizedSession() *sessions.SessionState {
return &sessions.SessionState{AccessToken: authorizedAccessToken}
}
func IsAuthorizedInHeader(reqHeader http.Header) bool {
return reqHeader.Get("Authorization") == fmt.Sprintf("Bearer %s", authorizedAccessToken)
}
func IsAuthorizedInURL(reqURL *url.URL) bool {
return reqURL.Query().Get("access_token") == authorizedAccessToken
}