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
|
|
|
|
}
|