mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-12-12 11:15:02 +02:00
24 lines
566 B
Go
24 lines
566 B
Go
package providers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/sessions"
|
|
)
|
|
|
|
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
|
|
}
|