Documentation
¶
Index ¶
- Constants
- Variables
- func AuthMethods(c Configuration) []string
- func AuthRequestError(w http.ResponseWriter, r *http.Request, authReq ErrAuthRequest, err error, ...)
- func AuthResponse(authReq AuthRequest, authorizer Authorizer, w http.ResponseWriter, ...)
- func AuthResponseCode(w http.ResponseWriter, r *http.Request, authReq AuthRequest, ...)
- func AuthResponseToken(w http.ResponseWriter, r *http.Request, authReq AuthRequest, ...)
- func Authorize(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
- func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
- func AuthorizeClient(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, Client, error)
- func AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string, storage OPStorage) error
- func BuildAuthRequestCode(authReq AuthRequest, crypto Crypto) (string, error)
- func CodeExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
- func CreateAccessToken(ctx context.Context, authReq AuthRequest, client Client, creator TokenCreator) (token string, validity time.Duration, err error)
- func CreateBearerToken(id string, crypto Crypto) (string, error)
- func CreateDiscoveryConfig(c Configuration, s Signer) *oidc.DiscoveryConfiguration
- func CreateIDToken(issuer string, authReq AuthRequest, validity time.Duration, ...) (string, error)
- func CreateJWT(issuer string, authReq AuthRequest, exp time.Time, id string, signer Signer) (string, error)
- func CreateRouter(o OpenIDProvider, h HttpInterceptor) *mux.Router
- func CreateTokenResponse(ctx context.Context, authReq AuthRequest, client Client, creator TokenCreator, ...) (*oidc.AccessTokenResponse, error)
- func Discover(w http.ResponseWriter, config *oidc.DiscoveryConfiguration)
- func EndSession(w http.ResponseWriter, r *http.Request, ender SessionEnder)
- func GrantTypes(c Configuration) []string
- func Healthz(w http.ResponseWriter, r *http.Request)
- func IsConfidentialType(c Client) bool
- func Keys(w http.ResponseWriter, r *http.Request, k KeyProvider)
- func NeedsExistingSession(authRequest *oidc.AuthRequest) bool
- func ParseAccessTokenRequest(r *http.Request, decoder *schema.Decoder) (*oidc.AccessTokenRequest, error)
- func ParseEndSessionRequest(r *http.Request, decoder *schema.Decoder) (*oidc.EndSessionRequest, error)
- func ParseTokenExchangeRequest(w http.ResponseWriter, r *http.Request) (oidc.TokenRequest, error)
- func Readiness(w http.ResponseWriter, r *http.Request, probes ...ProbesFn)
- func RedirectToLogin(authReqID string, client Client, w http.ResponseWriter, r *http.Request)
- func RequestError(w http.ResponseWriter, r *http.Request, err error)
- func ResponseTypes(c Configuration) []string
- func Scopes(c Configuration) []string
- func ScopesFromAccessToken(w http.ResponseWriter, r *http.Request) ([]string, error)
- func SigAlgorithms(s Signer) []string
- func Start(ctx context.Context, o OpenIDProvider)
- func SubjectTypes(c Configuration) []string
- func SupportedClaims(c Configuration) []string
- func TokenExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
- func Userinfo(w http.ResponseWriter, r *http.Request, userinfoProvider UserinfoProvider)
- func ValidateAccessTokenRequest(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, Client, error)
- func ValidateAuthReqRedirectURI(ctx context.Context, uri, client_id string, responseType oidc.ResponseType, ...) error
- func ValidateAuthReqResponseType(responseType oidc.ResponseType) error
- func ValidateAuthReqScopes(scopes []string) error
- func ValidateAuthRequest(ctx context.Context, authReq *oidc.AuthRequest, storage Storage) error
- func ValidateIssuer(issuer string) error
- func ValidateTokenExchangeRequest(tokenReq oidc.TokenRequest, storage Storage) error
- type AccessTokenType
- type ApplicationType
- type AuthMethod
- type AuthRequest
- type AuthStorage
- type Authorizer
- type Client
- type Config
- type Configuration
- type Crypto
- type DefaultOP
- func (p *DefaultOP) AuthMethodPostSupported() bool
- func (p *DefaultOP) AuthorizationEndpoint() Endpoint
- func (p *DefaultOP) Crypto() Crypto
- func (p *DefaultOP) Decoder() *schema.Decoder
- func (p *DefaultOP) DefaultLogoutRedirectURI() string
- func (p *DefaultOP) Encoder() *schema.Encoder
- func (p *DefaultOP) EndSessionEndpoint() Endpoint
- func (p *DefaultOP) HandleAuthorize(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleAuthorizeCallback(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleDiscovery(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleEndSession(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleExchange(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleKeys(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleReady(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HandleUserinfo(w http.ResponseWriter, r *http.Request)
- func (p *DefaultOP) HttpHandler() *http.Server
- func (p *DefaultOP) IDTokenVerifier() rp.Verifier
- func (p *DefaultOP) Issuer() string
- func (p *DefaultOP) KeysEndpoint() Endpoint
- func (p *DefaultOP) Port() string
- func (p *DefaultOP) Signer() Signer
- func (p *DefaultOP) Storage() Storage
- func (p *DefaultOP) TokenEndpoint() Endpoint
- func (p *DefaultOP) UserinfoEndpoint() Endpoint
- func (p *DefaultOP) VerifySignature(ctx context.Context, jws *jose.JSONWebSignature) ([]byte, error)
- type DefaultOPOpts
- func WithCustomAuthEndpoint(endpoint Endpoint) DefaultOPOpts
- func WithCustomEndSessionEndpoint(endpoint Endpoint) DefaultOPOpts
- func WithCustomKeysEndpoint(endpoint Endpoint) DefaultOPOpts
- func WithCustomTokenEndpoint(endpoint Endpoint) DefaultOPOpts
- func WithCustomUserinfoEndpoint(endpoint Endpoint) DefaultOPOpts
- func WithHttpInterceptor(h HttpInterceptor) DefaultOPOpts
- func WithRetry(max int, sleep time.Duration) DefaultOPOpts
- func WithTimer(timer <-chan time.Time) DefaultOPOpts
- type EndSessionRequest
- type Endpoint
- type ErrAuthRequest
- type Exchanger
- type HttpInterceptor
- type KeyProvider
- type OAuthError
- type OPStorage
- type OpenIDProvider
- type ProbesFn
- type SessionEnder
- type Signer
- type Storage
- type StorageNotFoundError
- type TokenCreator
- type UserinfoProvider
- type ValidationAuthorizer
Constants ¶
View Source
const ( ApplicationTypeWeb ApplicationType = iota ApplicationTypeUserAgent ApplicationTypeNative AccessTokenTypeBearer AccessTokenType = iota AccessTokenTypeJWT )
View Source
const ( AuthMethodBasic AuthMethod = "client_secret_basic" AuthMethodPost = "client_secret_post" AuthMethodNone = "none" )
View Source
const ( ScopeOpenID = "openid" ScopeProfile = "profile" ScopeEmail = "email" ScopePhone = "phone" ScopeAddress = "address" )
View Source
const ( InvalidRequest errorType = "invalid_request" ServerError errorType = "server_error" )
Variables ¶
View Source
var ( ErrInvalidRequest = func(description string) *OAuthError { return &OAuthError{ ErrorType: InvalidRequest, Description: description, } } ErrInvalidRequestRedirectURI = func(description string) *OAuthError { return &OAuthError{ ErrorType: InvalidRequest, Description: description, redirectDisabled: true, } } ErrServerError = func(description string) *OAuthError { return &OAuthError{ ErrorType: ServerError, Description: description, } } )
View Source
var ( DefaultEndpoints = &endpoints{ Authorization: NewEndpoint(defaultAuthorizationEndpoint), Token: NewEndpoint(defaulTokenEndpoint), Introspection: NewEndpoint(defaultIntrospectEndpoint), Userinfo: NewEndpoint(defaultUserinfoEndpoint), EndSession: NewEndpoint(defaultEndSessionEndpoint), JwksURI: NewEndpoint(defaultKeysEndpoint), } )
View Source
var DefaultInterceptor = func(h http.HandlerFunc) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { h(w, r) }) }
View Source
var DefaultSupportedScopes = []string{ ScopeOpenID, ScopeProfile, ScopeEmail, ScopePhone, ScopeAddress, }
Functions ¶
func AuthMethods ¶
func AuthMethods(c Configuration) []string
func AuthRequestError ¶
func AuthRequestError(w http.ResponseWriter, r *http.Request, authReq ErrAuthRequest, err error, encoder *schema.Encoder)
func AuthResponse ¶
func AuthResponse(authReq AuthRequest, authorizer Authorizer, w http.ResponseWriter, r *http.Request)
func AuthResponseCode ¶
func AuthResponseCode(w http.ResponseWriter, r *http.Request, authReq AuthRequest, authorizer Authorizer)
func AuthResponseToken ¶
func AuthResponseToken(w http.ResponseWriter, r *http.Request, authReq AuthRequest, authorizer Authorizer, client Client)
func Authorize ¶
func Authorize(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
func AuthorizeCallback ¶
func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
func AuthorizeClient ¶
func AuthorizeClient(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, Client, error)
func AuthorizeClientIDSecret ¶
func BuildAuthRequestCode ¶
func BuildAuthRequestCode(authReq AuthRequest, crypto Crypto) (string, error)
func CodeExchange ¶
func CodeExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
func CreateAccessToken ¶
func CreateAccessToken(ctx context.Context, authReq AuthRequest, client Client, creator TokenCreator) (token string, validity time.Duration, err error)
func CreateDiscoveryConfig ¶
func CreateDiscoveryConfig(c Configuration, s Signer) *oidc.DiscoveryConfiguration
func CreateIDToken ¶
func CreateRouter ¶
func CreateRouter(o OpenIDProvider, h HttpInterceptor) *mux.Router
func CreateTokenResponse ¶
func CreateTokenResponse(ctx context.Context, authReq AuthRequest, client Client, creator TokenCreator, createAccessToken bool, code string) (*oidc.AccessTokenResponse, error)
func Discover ¶
func Discover(w http.ResponseWriter, config *oidc.DiscoveryConfiguration)
func EndSession ¶ added in v0.4.0
func EndSession(w http.ResponseWriter, r *http.Request, ender SessionEnder)
func GrantTypes ¶
func GrantTypes(c Configuration) []string
func IsConfidentialType ¶
func Keys ¶
func Keys(w http.ResponseWriter, r *http.Request, k KeyProvider)
func NeedsExistingSession ¶
func NeedsExistingSession(authRequest *oidc.AuthRequest) bool
func ParseAccessTokenRequest ¶
func ParseEndSessionRequest ¶ added in v0.4.0
func ParseTokenExchangeRequest ¶
func ParseTokenExchangeRequest(w http.ResponseWriter, r *http.Request) (oidc.TokenRequest, error)
func Readiness ¶ added in v0.2.1
func Readiness(w http.ResponseWriter, r *http.Request, probes ...ProbesFn)
func RedirectToLogin ¶
func RequestError ¶ added in v0.4.0
func RequestError(w http.ResponseWriter, r *http.Request, err error)
func ResponseTypes ¶
func ResponseTypes(c Configuration) []string
func Scopes ¶
func Scopes(c Configuration) []string
func ScopesFromAccessToken ¶
func SigAlgorithms ¶
func Start ¶
func Start(ctx context.Context, o OpenIDProvider)
func SubjectTypes ¶
func SubjectTypes(c Configuration) []string
func SupportedClaims ¶
func SupportedClaims(c Configuration) []string
func TokenExchange ¶
func TokenExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
func Userinfo ¶
func Userinfo(w http.ResponseWriter, r *http.Request, userinfoProvider UserinfoProvider)
func ValidateAccessTokenRequest ¶
func ValidateAccessTokenRequest(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, Client, error)
func ValidateAuthReqResponseType ¶
func ValidateAuthReqResponseType(responseType oidc.ResponseType) error
func ValidateAuthReqScopes ¶
func ValidateAuthRequest ¶
func ValidateIssuer ¶
func ValidateTokenExchangeRequest ¶
func ValidateTokenExchangeRequest(tokenReq oidc.TokenRequest, storage Storage) error
Types ¶
type AccessTokenType ¶
type AccessTokenType int
type ApplicationType ¶
type ApplicationType int
type AuthMethod ¶
type AuthMethod string
type AuthRequest ¶
type AuthRequest interface {
GetID() string
GetACR() string
GetAMR() []string
GetAudience() []string
GetAuthTime() time.Time
GetClientID() string
GetCodeChallenge() *oidc.CodeChallenge
GetNonce() string
GetRedirectURI() string
GetResponseType() oidc.ResponseType
GetScopes() []string
GetState() string
GetSubject() string
Done() bool
}
func AuthRequestByCode ¶
func AuthRequestByCode(ctx context.Context, code string, crypto Crypto, storage AuthStorage) (AuthRequest, error)
func AuthorizeCodeChallenge ¶
func AuthorizeCodeChallenge(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, error)
type AuthStorage ¶
type AuthStorage interface {
CreateAuthRequest(context.Context, *oidc.AuthRequest) (AuthRequest, error)
AuthRequestByID(context.Context, string) (AuthRequest, error)
DeleteAuthRequest(context.Context, string) error
CreateToken(context.Context, AuthRequest) (string, time.Time, error)
TerminateSession(context.Context, string, string) error
GetSigningKey(context.Context, chan<- jose.SigningKey, chan<- error, <-chan time.Time)
GetKeySet(context.Context) (*jose.JSONWebKeySet, error)
SaveNewKeyPair(context.Context) error
}
type Authorizer ¶
type Client ¶
type Client interface {
GetID() string
RedirectURIs() []string
PostLogoutRedirectURIs() []string
ApplicationType() ApplicationType
GetAuthMethod() AuthMethod
LoginURL(string) string
AccessTokenType() AccessTokenType
IDTokenLifetime() time.Duration
}
type Config ¶
type Config struct {
Issuer string
CryptoKey [32]byte
DefaultLogoutRedirectURI string
// ScopesSupported: oidc.SupportedScopes,
// ResponseTypesSupported: responseTypes,
// GrantTypesSupported: oidc.SupportedGrantTypes,
// ClaimsSupported: oidc.SupportedClaims,
// IdTokenSigningAlgValuesSupported: []string{keys.SigningAlgorithm},
// SubjectTypesSupported: []string{"public"},
// TokenEndpointAuthMethodsSupported:
Port string
}
type Configuration ¶
type Crypto ¶
func NewAESCrypto ¶
type DefaultOP ¶
type DefaultOP struct {
// contains filtered or unexported fields
}
func (*DefaultOP) AuthMethodPostSupported ¶
func (*DefaultOP) AuthorizationEndpoint ¶
func (*DefaultOP) DefaultLogoutRedirectURI ¶ added in v0.4.0
func (*DefaultOP) EndSessionEndpoint ¶ added in v0.4.0
func (*DefaultOP) HandleAuthorize ¶
func (p *DefaultOP) HandleAuthorize(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleAuthorizeCallback ¶
func (p *DefaultOP) HandleAuthorizeCallback(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleDiscovery ¶
func (p *DefaultOP) HandleDiscovery(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleEndSession ¶ added in v0.4.0
func (p *DefaultOP) HandleEndSession(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleExchange ¶
func (p *DefaultOP) HandleExchange(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleKeys ¶
func (p *DefaultOP) HandleKeys(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleReady ¶ added in v0.2.1
func (p *DefaultOP) HandleReady(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HandleUserinfo ¶
func (p *DefaultOP) HandleUserinfo(w http.ResponseWriter, r *http.Request)
func (*DefaultOP) HttpHandler ¶
func (*DefaultOP) IDTokenVerifier ¶ added in v0.4.0
func (*DefaultOP) KeysEndpoint ¶
func (*DefaultOP) TokenEndpoint ¶
func (*DefaultOP) UserinfoEndpoint ¶
type DefaultOPOpts ¶
func WithCustomAuthEndpoint ¶
func WithCustomAuthEndpoint(endpoint Endpoint) DefaultOPOpts
func WithCustomEndSessionEndpoint ¶ added in v0.4.1
func WithCustomEndSessionEndpoint(endpoint Endpoint) DefaultOPOpts
func WithCustomKeysEndpoint ¶ added in v0.2.3
func WithCustomKeysEndpoint(endpoint Endpoint) DefaultOPOpts
func WithCustomTokenEndpoint ¶
func WithCustomTokenEndpoint(endpoint Endpoint) DefaultOPOpts
func WithCustomUserinfoEndpoint ¶
func WithCustomUserinfoEndpoint(endpoint Endpoint) DefaultOPOpts
func WithHttpInterceptor ¶ added in v0.2.0
func WithHttpInterceptor(h HttpInterceptor) DefaultOPOpts
func WithTimer ¶ added in v0.2.2
func WithTimer(timer <-chan time.Time) DefaultOPOpts
type EndSessionRequest ¶ added in v0.4.0
func ValidateEndSessionRequest ¶ added in v0.4.0
func ValidateEndSessionRequest(ctx context.Context, req *oidc.EndSessionRequest, ender SessionEnder) (*EndSessionRequest, error)
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func NewEndpoint ¶ added in v0.2.4
func NewEndpointWithURL ¶ added in v0.2.4
type ErrAuthRequest ¶
type ErrAuthRequest interface {
GetRedirectURI() string
GetResponseType() oidc.ResponseType
GetState() string
}
type HttpInterceptor ¶ added in v0.2.0
type HttpInterceptor func(http.HandlerFunc) http.HandlerFunc
type KeyProvider ¶
type KeyProvider interface {
Storage() Storage
}
type OAuthError ¶
type OAuthError struct {
ErrorType errorType `json:"error" schema:"error"`
Description string `json:"error_description" schema:"error_description"`
// contains filtered or unexported fields
}
func (*OAuthError) Error ¶
func (e *OAuthError) Error() string
type OpenIDProvider ¶
type OpenIDProvider interface {
Configuration
HandleReady(w http.ResponseWriter, r *http.Request)
HandleDiscovery(w http.ResponseWriter, r *http.Request)
HandleAuthorize(w http.ResponseWriter, r *http.Request)
HandleAuthorizeCallback(w http.ResponseWriter, r *http.Request)
HandleExchange(w http.ResponseWriter, r *http.Request)
HandleUserinfo(w http.ResponseWriter, r *http.Request)
HandleEndSession(w http.ResponseWriter, r *http.Request)
HandleKeys(w http.ResponseWriter, r *http.Request)
HttpHandler() *http.Server
}
func NewDefaultOP ¶
func NewDefaultOP(ctx context.Context, config *Config, storage Storage, opOpts ...DefaultOPOpts) (OpenIDProvider, error)
type ProbesFn ¶ added in v0.2.1
func ReadySigner ¶ added in v0.2.1
func ReadyStorage ¶ added in v0.2.1
type SessionEnder ¶ added in v0.4.0
type Signer ¶
type Signer interface {
Health(ctx context.Context) error
SignIDToken(claims *oidc.IDTokenClaims) (string, error)
SignAccessToken(claims *oidc.AccessTokenClaims) (string, error)
SignatureAlgorithm() jose.SignatureAlgorithm
}
func NewDefaultSigner ¶
func NewDefaultSigner(ctx context.Context, storage AuthStorage, keyCh <-chan jose.SigningKey) Signer
type StorageNotFoundError ¶ added in v0.2.1
type StorageNotFoundError interface {
IsNotFound()
}
type TokenCreator ¶
type UserinfoProvider ¶
type UserinfoProvider interface {
Storage() Storage
}
type ValidationAuthorizer ¶
type ValidationAuthorizer interface {
Authorizer
ValidateAuthRequest(context.Context, *oidc.AuthRequest, Storage) error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.