mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-11-24 08:52:25 +02:00
3fa42edb73
* fix import path for v7 find ./ -name "*.go" | xargs sed -i -e 's|"github.com/oauth2-proxy/oauth2-proxy|"github.com/oauth2-proxy/oauth2-proxy/v7|' * fix module path * go mod tidy * fix installation docs * update CHANGELOG * Update CHANGELOG.md Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk> Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
24 lines
569 B
Go
24 lines
569 B
Go
package providers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/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
|
|
}
|