Documentation ¶
Index ¶
- Constants
- Variables
- func AuthCallbackURL(o OpenIDProvider) func(string) string
- func AuthMethodsIntrospectionEndpoint(c Configuration) []oidc.AuthMethod
- func AuthMethodsRevocationEndpoint(c Configuration) []oidc.AuthMethod
- func AuthMethodsTokenEndpoint(c Configuration) []oidc.AuthMethod
- 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 AuthResponseURL(redirectURI string, responseType oidc.ResponseType, ...) (string, error)
- func Authorize(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
- func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
- func AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string, storage Storage) error
- func AuthorizeCodeChallenge(tokenReq *oidc.AccessTokenRequest, challenge *oidc.CodeChallenge) error
- func AuthorizeCodeClient(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (request AuthRequest, client Client, err error)
- func AuthorizeRefreshClient(ctx context.Context, tokenReq *oidc.RefreshTokenRequest, exchanger Exchanger) (request RefreshTokenRequest, client Client, err error)
- func BuildAuthRequestCode(authReq AuthRequest, crypto Crypto) (string, error)
- func CodeChallengeMethods(c Configuration) []oidc.CodeChallengeMethod
- func CodeExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
- func ContainsResponseType(types []oidc.ResponseType, responseType oidc.ResponseType) bool
- func CopyRequestObjectToAuthRequest(authReq *oidc.AuthRequest, requestObject *oidc.RequestObject)
- func CreateAccessToken(ctx context.Context, tokenRequest TokenRequest, ...) (accessToken, newRefreshToken string, validity time.Duration, err error)
- func CreateAuthRequestCode(ctx context.Context, authReq AuthRequest, storage Storage, crypto Crypto) (string, error)
- func CreateBearerToken(tokenID, subject string, crypto Crypto) (string, error)
- func CreateDiscoveryConfig(c Configuration, s Signer) *oidc.DiscoveryConfiguration
- func CreateIDToken(ctx context.Context, issuer string, request IDTokenRequest, ...) (string, error)
- func CreateJWT(ctx context.Context, issuer string, tokenRequest TokenRequest, exp time.Time, ...) (string, error)
- func CreateJWTTokenResponse(ctx context.Context, tokenRequest TokenRequest, creator TokenCreator) (*oidc.AccessTokenResponse, error)
- func CreateRouter(o OpenIDProvider, interceptors ...HttpInterceptor) *mux.Router
- func CreateTokenResponse(ctx context.Context, request IDTokenRequest, client Client, ...) (*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) []oidc.GrantType
- func HTTPLoopbackOrLocalhost(rawurl string) (*url.URL, bool)
- func Introspect(w http.ResponseWriter, r *http.Request, introspector Introspector)
- func IntrospectionSigAlgorithms(c Configuration) []string
- func IsConfidentialType(c Client) bool
- func JWTProfile(w http.ResponseWriter, r *http.Request, ...)
- func Keys(w http.ResponseWriter, r *http.Request, k KeyProvider)
- func ParseAccessTokenRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.AccessTokenRequest, error)
- func ParseAuthenticatedTokenRequest(r *http.Request, decoder httphelper.Decoder, request AuthenticatedTokenRequest) error
- func ParseAuthorizeRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.AuthRequest, error)
- func ParseEndSessionRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.EndSessionRequest, error)
- func ParseJWTProfileGrantRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.JWTProfileGrantRequest, error)
- func ParseJWTProfileRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.JWTProfileGrantRequest, error)
- func ParseRefreshTokenRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.RefreshTokenRequest, error)
- func ParseRequestObject(ctx context.Context, authReq *oidc.AuthRequest, storage Storage, issuer string) (*oidc.AuthRequest, error)
- func ParseTokenIntrospectionRequest(r *http.Request, introspector Introspector) (token, clientID string, err error)
- func ParseTokenRevocationRequest(r *http.Request, revoker Revoker) (token, tokenTypeHint, clientID string, err error)
- func ParseUserinfoRequest(r *http.Request, decoder httphelper.Decoder) (string, error)
- func Readiness(w http.ResponseWriter, r *http.Request, probes ...ProbesFn)
- func RedirectToLogin(authReqID string, client Client, w http.ResponseWriter, r *http.Request)
- func RefreshTokenExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
- func RequestError(w http.ResponseWriter, r *http.Request, err error)
- func RequestObjectSigAlgorithms(c Configuration) []string
- func ResponseTypes(c Configuration) []string
- func RevocationRequestError(w http.ResponseWriter, r *http.Request, err error)
- func RevocationSigAlgorithms(c Configuration) []string
- func Revoke(w http.ResponseWriter, r *http.Request, revoker Revoker)
- func Scopes(c Configuration) []string
- func SigAlgorithms(s Signer) []string
- func SubjectIsIssuer(request *oidc.JWTTokenRequest) error
- func SubjectTypes(c Configuration) []string
- func SupportedClaims(c Configuration) []string
- func TokenExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
- func TokenSigAlgorithms(c Configuration) []string
- func Userinfo(w http.ResponseWriter, r *http.Request, userinfoProvider UserinfoProvider)
- func ValidateAccessTokenRequest(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (AuthRequest, Client, error)
- func ValidateAuthReqIDTokenHint(ctx context.Context, idTokenHint string, verifier IDTokenHintVerifier) (string, error)
- func ValidateAuthReqPrompt(prompts []string, maxAge *uint) (_ *uint, err error)
- func ValidateAuthReqRedirectURI(client Client, uri string, responseType oidc.ResponseType) error
- func ValidateAuthReqResponseType(client Client, responseType oidc.ResponseType) error
- func ValidateAuthReqScopes(client Client, scopes []string) ([]string, error)
- func ValidateAuthRequest(ctx context.Context, authReq *oidc.AuthRequest, storage Storage, ...) (sub string, err error)
- func ValidateGrantType(client Client, grantType oidc.GrantType) bool
- func ValidateIssuer(issuer string) error
- func ValidateRefreshTokenRequest(ctx context.Context, tokenReq *oidc.RefreshTokenRequest, exchanger Exchanger) (RefreshTokenRequest, Client, error)
- func ValidateRefreshTokenScopes(requestedScopes []string, authRequest RefreshTokenRequest) error
- func VerifyAccessToken(ctx context.Context, token string, v AccessTokenVerifier) (oidc.AccessTokenClaims, error)
- func VerifyIDTokenHint(ctx context.Context, token string, v IDTokenHintVerifier) (oidc.IDTokenClaims, error)
- func VerifyJWTAssertion(ctx context.Context, assertion string, v JWTProfileVerifier) (*oidc.JWTTokenRequest, error)
- type AccessTokenType
- type AccessTokenVerifier
- type ApplicationType
- type AuthMethod
- type AuthRequest
- type AuthStorage
- type AuthenticatedTokenRequest
- type AuthorizeValidator
- type Authorizer
- type Client
- type Config
- type Configuration
- type Crypto
- type EndSessionRequest
- type Endpoint
- type ErrAuthRequest
- type Exchanger
- type HttpInterceptor
- type IDTokenHintVerifier
- type IDTokenRequest
- type Introspector
- type IntrospectorJWTProfile
- type JWTAuthorizationGrantExchanger
- type JWTProfileVerifier
- type JWTProfileVerifierOption
- type KeyProvider
- type OPStorage
- type OpenIDProvider
- type Option
- func WithCustomAuthEndpoint(endpoint Endpoint) Option
- func WithCustomEndSessionEndpoint(endpoint Endpoint) Option
- func WithCustomEndpoints(auth, token, userInfo, revocation, endSession, keys Endpoint) Option
- func WithCustomIntrospectionEndpoint(endpoint Endpoint) Option
- func WithCustomKeysEndpoint(endpoint Endpoint) Option
- func WithCustomRevocationEndpoint(endpoint Endpoint) Option
- func WithCustomTokenEndpoint(endpoint Endpoint) Option
- func WithCustomUserinfoEndpoint(endpoint Endpoint) Option
- func WithHttpInterceptors(interceptors ...HttpInterceptor) Option
- type ProbesFn
- type RefreshTokenRequest
- type Revoker
- type RevokerJWTProfile
- type SessionEnder
- type Signer
- type Storage
- type StorageNotFoundError
- type TokenCreator
- type TokenRequest
- type UserinfoProvider
Constants ¶
const OidcDevMode = "CAOS_OIDC_DEV"
Variables ¶
var ( DefaultEndpoints = &endpoints{ Authorization: NewEndpoint(defaultAuthorizationEndpoint), Token: NewEndpoint(defaultTokenEndpoint), Introspection: NewEndpoint(defaultIntrospectEndpoint), Userinfo: NewEndpoint(defaultUserinfoEndpoint), Revocation: NewEndpoint(defaultRevocationEndpoint), EndSession: NewEndpoint(defaultEndSessionEndpoint), JwksURI: NewEndpoint(defaultKeysEndpoint), } )
var DefaultSupportedScopes = []string{ oidc.ScopeOpenID, oidc.ScopeProfile, oidc.ScopeEmail, oidc.ScopePhone, oidc.ScopeAddress, oidc.ScopeOfflineAccess, }
Functions ¶
func AuthCallbackURL ¶ added in v1.2.0
func AuthCallbackURL(o OpenIDProvider) func(string) string
AuthCallbackURL builds the url for the redirect (with the requestID) after a successful login
func AuthMethodsIntrospectionEndpoint ¶ added in v0.14.0
func AuthMethodsIntrospectionEndpoint(c Configuration) []oidc.AuthMethod
func AuthMethodsRevocationEndpoint ¶ added in v1.0.0
func AuthMethodsRevocationEndpoint(c Configuration) []oidc.AuthMethod
func AuthMethodsTokenEndpoint ¶ added in v0.14.0
func AuthMethodsTokenEndpoint(c Configuration) []oidc.AuthMethod
func AuthRequestError ¶
func AuthRequestError(w http.ResponseWriter, r *http.Request, authReq ErrAuthRequest, err error, encoder httphelper.Encoder)
func AuthResponse ¶
func AuthResponse(authReq AuthRequest, authorizer Authorizer, w http.ResponseWriter, r *http.Request)
AuthResponse creates the successful authentication response (either code or tokens)
func AuthResponseCode ¶
func AuthResponseCode(w http.ResponseWriter, r *http.Request, authReq AuthRequest, authorizer Authorizer)
AuthResponseCode creates the successful code authentication response
func AuthResponseToken ¶
func AuthResponseToken(w http.ResponseWriter, r *http.Request, authReq AuthRequest, authorizer Authorizer, client Client)
AuthResponseToken creates the successful token(s) authentication response
func AuthResponseURL ¶ added in v1.0.0
func AuthResponseURL(redirectURI string, responseType oidc.ResponseType, responseMode oidc.ResponseMode, response interface{}, encoder httphelper.Encoder) (string, error)
AuthResponseURL encodes the authorization response (successful and error) and sets it as query or fragment values depending on the response_mode and response_type
func Authorize ¶
func Authorize(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
Authorize handles the authorization request, including parsing, validating, storing and finally redirecting to the login handler
func AuthorizeCallback ¶
func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer)
AuthorizeCallback handles the callback after authentication in the Login UI
func AuthorizeClientIDSecret ¶
func AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string, storage Storage) error
AuthorizeClientIDSecret authorizes a client by validating the client_id and client_secret (Basic Auth and POST)
func AuthorizeCodeChallenge ¶
func AuthorizeCodeChallenge(tokenReq *oidc.AccessTokenRequest, challenge *oidc.CodeChallenge) error
AuthorizeCodeChallenge authorizes a client by validating the code_verifier against the previously sent code_challenge of the auth request (PKCE)
func AuthorizeCodeClient ¶ added in v0.15.0
func AuthorizeCodeClient(ctx context.Context, tokenReq *oidc.AccessTokenRequest, exchanger Exchanger) (request AuthRequest, client Client, err error)
AuthorizeCodeClient checks the authorization of the client and that the used method was the one previously registered. It than returns the auth request corresponding to the auth code
func AuthorizeRefreshClient ¶ added in v0.15.0
func AuthorizeRefreshClient(ctx context.Context, tokenReq *oidc.RefreshTokenRequest, exchanger Exchanger) (request RefreshTokenRequest, client Client, err error)
AuthorizeRefreshClient checks the authorization of the client and that the used method was the one previously registered. It than returns the data representing the original auth request corresponding to the refresh_token
func BuildAuthRequestCode ¶
func BuildAuthRequestCode(authReq AuthRequest, crypto Crypto) (string, error)
BuildAuthRequestCode builds the string representation of the auth code
func CodeChallengeMethods ¶ added in v0.7.1
func CodeChallengeMethods(c Configuration) []oidc.CodeChallengeMethod
func CodeExchange ¶
func CodeExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
CodeExchange handles the OAuth 2.0 authorization_code grant, including parsing, validating, authorizing the client and finally exchanging the code for tokens
func ContainsResponseType ¶ added in v0.7.0
func ContainsResponseType(types []oidc.ResponseType, responseType oidc.ResponseType) bool
func CopyRequestObjectToAuthRequest ¶ added in v1.0.0
func CopyRequestObjectToAuthRequest(authReq *oidc.AuthRequest, requestObject *oidc.RequestObject)
CopyRequestObjectToAuthRequest overwrites present values from the Request Object into the auth request and clears the `RequestParam` of the auth request
func CreateAccessToken ¶
func CreateAccessToken(ctx context.Context, tokenRequest TokenRequest, accessTokenType AccessTokenType, creator TokenCreator, client Client, refreshToken string) (accessToken, newRefreshToken string, validity time.Duration, err error)
func CreateAuthRequestCode ¶ added in v0.6.2
func CreateAuthRequestCode(ctx context.Context, authReq AuthRequest, storage Storage, crypto Crypto) (string, error)
CreateAuthRequestCode creates and stores a code for the auth code response
func CreateBearerToken ¶
func CreateDiscoveryConfig ¶
func CreateDiscoveryConfig(c Configuration, s Signer) *oidc.DiscoveryConfiguration
func CreateIDToken ¶
func CreateJWTTokenResponse ¶ added in v0.9.0
func CreateJWTTokenResponse(ctx context.Context, tokenRequest TokenRequest, creator TokenCreator) (*oidc.AccessTokenResponse, error)
CreateJWTTokenResponse creates
func CreateRouter ¶
func CreateRouter(o OpenIDProvider, interceptors ...HttpInterceptor) *mux.Router
func CreateTokenResponse ¶
func CreateTokenResponse(ctx context.Context, request IDTokenRequest, client Client, creator TokenCreator, createAccessToken bool, code, refreshToken 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) []oidc.GrantType
func HTTPLoopbackOrLocalhost ¶ added in v0.14.7
func Introspect ¶ added in v0.14.0
func Introspect(w http.ResponseWriter, r *http.Request, introspector Introspector)
func IntrospectionSigAlgorithms ¶ added in v1.0.0
func IntrospectionSigAlgorithms(c Configuration) []string
func IsConfidentialType ¶
func JWTProfile ¶ added in v0.9.0
func JWTProfile(w http.ResponseWriter, r *http.Request, exchanger JWTAuthorizationGrantExchanger)
JWTProfile handles the OAuth 2.0 JWT Profile Authorization Grant https://tools.ietf.org/html/rfc7523#section-2.1
func Keys ¶
func Keys(w http.ResponseWriter, r *http.Request, k KeyProvider)
func ParseAccessTokenRequest ¶
func ParseAccessTokenRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.AccessTokenRequest, error)
ParseAccessTokenRequest parsed the http request into a oidc.AccessTokenRequest
func ParseAuthenticatedTokenRequest ¶ added in v0.15.0
func ParseAuthenticatedTokenRequest(r *http.Request, decoder httphelper.Decoder, request AuthenticatedTokenRequest) error
ParseAuthenticatedTokenRequest parses the client_id and client_secret from the HTTP request from either HTTP Basic Auth header or form body and sets them into the provided authenticatedTokenRequest interface
func ParseAuthorizeRequest ¶ added in v0.7.5
func ParseAuthorizeRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.AuthRequest, error)
ParseAuthorizeRequest parsed the http request into an oidc.AuthRequest
func ParseEndSessionRequest ¶ added in v0.4.0
func ParseEndSessionRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.EndSessionRequest, error)
func ParseJWTProfileGrantRequest ¶ added in v0.15.0
func ParseJWTProfileGrantRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.JWTProfileGrantRequest, error)
func ParseJWTProfileRequest ¶ added in v0.9.0
func ParseJWTProfileRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.JWTProfileGrantRequest, error)
ParseJWTProfileRequest has been renamed to ParseJWTProfileGrantRequest
deprecated: use ParseJWTProfileGrantRequest
func ParseRefreshTokenRequest ¶ added in v0.15.0
func ParseRefreshTokenRequest(r *http.Request, decoder httphelper.Decoder) (*oidc.RefreshTokenRequest, error)
ParseRefreshTokenRequest parsed the http request into a oidc.RefreshTokenRequest
func ParseRequestObject ¶ added in v1.0.0
func ParseRequestObject(ctx context.Context, authReq *oidc.AuthRequest, storage Storage, issuer string) (*oidc.AuthRequest, error)
ParseRequestObject parse the `request` parameter, validates the token including the signature and copies the token claims into the auth request
func ParseTokenIntrospectionRequest ¶ added in v0.14.0
func ParseTokenIntrospectionRequest(r *http.Request, introspector Introspector) (token, clientID string, err error)
func ParseTokenRevocationRequest ¶ added in v1.0.0
func ParseUserinfoRequest ¶ added in v0.14.0
func Readiness ¶ added in v0.2.1
func Readiness(w http.ResponseWriter, r *http.Request, probes ...ProbesFn)
func RedirectToLogin ¶
RedirectToLogin redirects the end user to the Login UI for authentication
func RefreshTokenExchange ¶ added in v0.15.0
func RefreshTokenExchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger)
RefreshTokenExchange handles the OAuth 2.0 refresh_token grant, including parsing, validating, authorizing the client and finally exchanging the refresh_token for new tokens
func RequestError ¶ added in v0.4.0
func RequestError(w http.ResponseWriter, r *http.Request, err error)
func RequestObjectSigAlgorithms ¶ added in v1.0.0
func RequestObjectSigAlgorithms(c Configuration) []string
func ResponseTypes ¶
func ResponseTypes(c Configuration) []string
func RevocationRequestError ¶ added in v1.0.0
func RevocationRequestError(w http.ResponseWriter, r *http.Request, err error)
func RevocationSigAlgorithms ¶ added in v1.0.0
func RevocationSigAlgorithms(c Configuration) []string
func Scopes ¶
func Scopes(c Configuration) []string
func SigAlgorithms ¶
func SubjectIsIssuer ¶ added in v0.15.5
func SubjectIsIssuer(request *oidc.JWTTokenRequest) error
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)
TokenExchange will handle the OAuth 2.0 token exchange grant ("urn:ietf:params:oauth:grant-type:token-exchange")
func TokenSigAlgorithms ¶ added in v1.0.0
func TokenSigAlgorithms(c Configuration) []string
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)
ValidateAccessTokenRequest validates the token request parameters including authorization check of the client and returns the previous created auth request corresponding to the auth code
func ValidateAuthReqIDTokenHint ¶ added in v0.5.0
func ValidateAuthReqIDTokenHint(ctx context.Context, idTokenHint string, verifier IDTokenHintVerifier) (string, error)
ValidateAuthReqIDTokenHint validates the id_token_hint (if passed as parameter in the request) and returns the `sub` claim
func ValidateAuthReqPrompt ¶ added in v0.15.3
ValidateAuthReqPrompt validates the passed prompt values and sets max_age to 0 if prompt login is present
func ValidateAuthReqRedirectURI ¶
func ValidateAuthReqRedirectURI(client Client, uri string, responseType oidc.ResponseType) error
ValidateAuthReqRedirectURI validates the passed redirect_uri and response_type to the registered uris and client type
func ValidateAuthReqResponseType ¶
func ValidateAuthReqResponseType(client Client, responseType oidc.ResponseType) error
ValidateAuthReqResponseType validates the passed response_type to the registered response types
func ValidateAuthReqScopes ¶
ValidateAuthReqScopes validates the passed scopes
func ValidateAuthRequest ¶
func ValidateAuthRequest(ctx context.Context, authReq *oidc.AuthRequest, storage Storage, verifier IDTokenHintVerifier) (sub string, err error)
ValidateAuthRequest validates the authorize parameters and returns the userID of the id_token_hint if passed
func ValidateGrantType ¶ added in v0.15.1
ValidateGrantType ensures that the requested grant_type is allowed by the Client
func ValidateIssuer ¶
func ValidateRefreshTokenRequest ¶ added in v0.15.0
func ValidateRefreshTokenRequest(ctx context.Context, tokenReq *oidc.RefreshTokenRequest, exchanger Exchanger) (RefreshTokenRequest, Client, error)
ValidateRefreshTokenRequest validates the refresh_token request parameters including authorization check of the client and returns the data representing the original auth request corresponding to the refresh_token
func ValidateRefreshTokenScopes ¶ added in v0.15.0
func ValidateRefreshTokenScopes(requestedScopes []string, authRequest RefreshTokenRequest) error
ValidateRefreshTokenScopes validates that the requested scope is a subset of the original auth request scope it will set the requested scopes as current scopes onto RefreshTokenRequest if empty the original scopes will be used
func VerifyAccessToken ¶ added in v0.12.0
func VerifyAccessToken(ctx context.Context, token string, v AccessTokenVerifier) (oidc.AccessTokenClaims, error)
VerifyAccessToken validates the access token (issuer, signature and expiration)
func VerifyIDTokenHint ¶ added in v0.9.0
func VerifyIDTokenHint(ctx context.Context, token string, v IDTokenHintVerifier) (oidc.IDTokenClaims, error)
VerifyIDTokenHint validates the id token according to https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
func VerifyJWTAssertion ¶ added in v0.9.0
func VerifyJWTAssertion(ctx context.Context, assertion string, v JWTProfileVerifier) (*oidc.JWTTokenRequest, error)
VerifyJWTAssertion verifies the assertion string from JWT Profile (authorization grant and client authentication)
checks audience, exp, iat, signature and that issuer and sub are the same
Types ¶
type AccessTokenType ¶
type AccessTokenType int
const ( AccessTokenTypeBearer AccessTokenType = iota AccessTokenTypeJWT )
type AccessTokenVerifier ¶ added in v0.12.0
type AccessTokenVerifier interface { oidc.Verifier SupportedSignAlgs() []string KeySet() oidc.KeySet }
func NewAccessTokenVerifier ¶ added in v0.12.0
func NewAccessTokenVerifier(issuer string, keySet oidc.KeySet) AccessTokenVerifier
type ApplicationType ¶
type ApplicationType int
const ( ApplicationTypeWeb ApplicationType = iota ApplicationTypeUserAgent ApplicationTypeNative )
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 GetResponseMode() oidc.ResponseMode GetScopes() []string GetState() string GetSubject() string Done() bool }
func AuthRequestByCode ¶
AuthRequestByCode returns the AuthRequest previously created from Storage corresponding to the auth code or an error
type AuthStorage ¶
type AuthStorage interface { CreateAuthRequest(context.Context, *oidc.AuthRequest, string) (AuthRequest, error) AuthRequestByID(context.Context, string) (AuthRequest, error) AuthRequestByCode(context.Context, string) (AuthRequest, error) SaveAuthCode(context.Context, string, string) error DeleteAuthRequest(context.Context, string) error CreateAccessToken(context.Context, TokenRequest) (string, time.Time, error) CreateAccessAndRefreshTokens(ctx context.Context, request TokenRequest, currentRefreshToken string) (accessTokenID string, newRefreshToken string, expiration time.Time, err error) TokenRequestByRefreshToken(ctx context.Context, refreshToken string) (RefreshTokenRequest, error) TerminateSession(ctx context.Context, userID string, clientID string) error RevokeToken(ctx context.Context, token string, userID string, clientID string) *oidc.Error GetSigningKey(context.Context, chan<- jose.SigningKey) GetKeySet(context.Context) (*jose.JSONWebKeySet, error) }
type AuthenticatedTokenRequest ¶ added in v0.15.0
AuthenticatedTokenRequest is a helper interface for ParseAuthenticatedTokenRequest it is implemented by oidc.AuthRequest and oidc.RefreshTokenRequest
type AuthorizeValidator ¶ added in v0.7.5
type AuthorizeValidator interface { Authorizer ValidateAuthRequest(context.Context, *oidc.AuthRequest, Storage, IDTokenHintVerifier) (string, error) }
AuthorizeValidator is an extension of Authorizer interface implementing its own validation mechanism for the auth request
type Authorizer ¶
type Authorizer interface { Storage() Storage Decoder() httphelper.Decoder Encoder() httphelper.Encoder Signer() Signer IDTokenHintVerifier() IDTokenHintVerifier Crypto() Crypto Issuer() string RequestObjectSupported() bool }
type Client ¶
type Client interface { GetID() string RedirectURIs() []string PostLogoutRedirectURIs() []string ApplicationType() ApplicationType AuthMethod() oidc.AuthMethod ResponseTypes() []oidc.ResponseType GrantTypes() []oidc.GrantType LoginURL(string) string AccessTokenType() AccessTokenType IDTokenLifetime() time.Duration DevMode() bool RestrictAdditionalIdTokenScopes() func(scopes []string) []string RestrictAdditionalAccessTokenScopes() func(scopes []string) []string IsScopeAllowed(scope string) bool IDTokenUserinfoClaimsAssertion() bool ClockSkew() time.Duration }
func AuthorizePrivateJWTKey ¶ added in v0.14.0
func AuthorizePrivateJWTKey(ctx context.Context, clientAssertion string, exchanger JWTAuthorizationGrantExchanger) (Client, error)
AuthorizePrivateJWTKey authorizes a client by validating the client_assertion's signature with a previously registered public key (JWT Profile)
type Configuration ¶
type Configuration interface { Issuer() string AuthorizationEndpoint() Endpoint TokenEndpoint() Endpoint IntrospectionEndpoint() Endpoint UserinfoEndpoint() Endpoint RevocationEndpoint() Endpoint EndSessionEndpoint() Endpoint KeysEndpoint() Endpoint AuthMethodPostSupported() bool CodeMethodS256Supported() bool AuthMethodPrivateKeyJWTSupported() bool TokenEndpointSigningAlgorithmsSupported() []string GrantTypeRefreshTokenSupported() bool GrantTypeTokenExchangeSupported() bool GrantTypeJWTAuthorizationSupported() bool IntrospectionAuthMethodPrivateKeyJWTSupported() bool IntrospectionEndpointSigningAlgorithmsSupported() []string RevocationAuthMethodPrivateKeyJWTSupported() bool RevocationEndpointSigningAlgorithmsSupported() []string RequestObjectSupported() bool RequestObjectSigningAlgorithmsSupported() []string SupportedUILocales() []language.Tag }
type Crypto ¶
func NewAESCrypto ¶
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 Exchanger ¶
type Exchanger interface { Issuer() string Storage() Storage Decoder() httphelper.Decoder Signer() Signer Crypto() Crypto AuthMethodPostSupported() bool AuthMethodPrivateKeyJWTSupported() bool GrantTypeRefreshTokenSupported() bool GrantTypeTokenExchangeSupported() bool GrantTypeJWTAuthorizationSupported() bool }
type IDTokenHintVerifier ¶ added in v0.9.0
type IDTokenHintVerifier interface { oidc.Verifier SupportedSignAlgs() []string KeySet() oidc.KeySet ACR() oidc.ACRVerifier MaxAge() time.Duration }
func NewIDTokenHintVerifier ¶ added in v0.9.0
func NewIDTokenHintVerifier(issuer string, keySet oidc.KeySet) IDTokenHintVerifier
type IDTokenRequest ¶ added in v0.15.0
type Introspector ¶ added in v0.14.0
type Introspector interface { Decoder() httphelper.Decoder Crypto() Crypto Storage() Storage AccessTokenVerifier() AccessTokenVerifier }
type IntrospectorJWTProfile ¶ added in v0.14.0
type IntrospectorJWTProfile interface { Introspector JWTProfileVerifier() JWTProfileVerifier }
type JWTAuthorizationGrantExchanger ¶ added in v0.12.2
type JWTAuthorizationGrantExchanger interface { Exchanger JWTProfileVerifier() JWTProfileVerifier }
type JWTProfileVerifier ¶ added in v0.9.0
type JWTProfileVerifier interface { oidc.Verifier Storage() jwtProfileKeyStorage CheckSubject(request *oidc.JWTTokenRequest) error }
func NewJWTProfileVerifier ¶ added in v0.9.0
func NewJWTProfileVerifier(storage jwtProfileKeyStorage, issuer string, maxAgeIAT, offset time.Duration, opts ...JWTProfileVerifierOption) JWTProfileVerifier
NewJWTProfileVerifier creates a oidc.Verifier for JWT Profile assertions (authorization grant and client authentication)
type JWTProfileVerifierOption ¶ added in v0.15.5
type JWTProfileVerifierOption func(*jwtProfileVerifier)
func SubjectCheck ¶ added in v0.15.5
func SubjectCheck(check func(request *oidc.JWTTokenRequest) error) JWTProfileVerifierOption
type KeyProvider ¶
type OPStorage ¶
type OPStorage interface { GetClientByClientID(ctx context.Context, clientID string) (Client, error) AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string) error SetUserinfoFromScopes(ctx context.Context, userinfo oidc.UserInfoSetter, userID, clientID string, scopes []string) error SetUserinfoFromToken(ctx context.Context, userinfo oidc.UserInfoSetter, tokenID, subject, origin string) error SetIntrospectionFromToken(ctx context.Context, userinfo oidc.IntrospectionResponse, tokenID, subject, clientID string) error GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]interface{}, error) GetKeyByIDAndUserID(ctx context.Context, keyID, userID string) (*jose.JSONWebKey, error) ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error) }
type OpenIDProvider ¶
type OpenIDProvider interface { Configuration Storage() Storage Decoder() httphelper.Decoder Encoder() httphelper.Encoder IDTokenHintVerifier() IDTokenHintVerifier AccessTokenVerifier() AccessTokenVerifier Crypto() Crypto DefaultLogoutRedirectURI() string Signer() Signer Probes() []ProbesFn HttpHandler() http.Handler }
func NewOpenIDProvider ¶ added in v0.9.0
type Option ¶ added in v0.9.0
type Option func(o *openidProvider) error
func WithCustomAuthEndpoint ¶
func WithCustomEndSessionEndpoint ¶ added in v0.4.1
func WithCustomEndpoints ¶ added in v0.9.0
func WithCustomIntrospectionEndpoint ¶ added in v0.14.0
func WithCustomKeysEndpoint ¶ added in v0.2.3
func WithCustomRevocationEndpoint ¶ added in v1.0.0
func WithCustomTokenEndpoint ¶
func WithHttpInterceptors ¶ added in v0.7.4
func WithHttpInterceptors(interceptors ...HttpInterceptor) Option
type ProbesFn ¶ added in v0.2.1
func ReadySigner ¶ added in v0.2.1
func ReadyStorage ¶ added in v0.2.1
type RefreshTokenRequest ¶ added in v0.15.0
type RefreshTokenRequest interface { GetAMR() []string GetAudience() []string GetAuthTime() time.Time GetClientID() string GetScopes() []string GetSubject() string SetCurrentScopes(scopes []string) }
func RefreshTokenRequestByRefreshToken ¶ added in v0.15.0
func RefreshTokenRequestByRefreshToken(ctx context.Context, storage Storage, refreshToken string) (RefreshTokenRequest, error)
RefreshTokenRequestByRefreshToken returns the RefreshTokenRequest (data representing the original auth request) corresponding to the refresh_token from Storage or an error
type Revoker ¶ added in v1.0.0
type Revoker interface { Decoder() httphelper.Decoder Crypto() Crypto Storage() Storage AccessTokenVerifier() AccessTokenVerifier AuthMethodPrivateKeyJWTSupported() bool AuthMethodPostSupported() bool }
type RevokerJWTProfile ¶ added in v1.0.0
type RevokerJWTProfile interface { Revoker JWTProfileVerifier() JWTProfileVerifier }
type SessionEnder ¶ added in v0.4.0
type SessionEnder interface { Decoder() httphelper.Decoder Storage() Storage IDTokenHintVerifier() IDTokenHintVerifier DefaultLogoutRedirectURI() string }
type Signer ¶
type StorageNotFoundError ¶ added in v0.2.1
type StorageNotFoundError interface {
IsNotFound()
}
type TokenCreator ¶
type TokenRequest ¶ added in v0.9.0
type UserinfoProvider ¶
type UserinfoProvider interface { Decoder() httphelper.Decoder Crypto() Crypto Storage() Storage AccessTokenVerifier() AccessTokenVerifier }
Source Files ¶
- auth_request.go
- client.go
- config.go
- crypto.go
- discovery.go
- endpoint.go
- error.go
- keys.go
- op.go
- probes.go
- session.go
- signer.go
- storage.go
- token.go
- token_code.go
- token_exchange.go
- token_intospection.go
- token_jwt_profile.go
- token_refresh.go
- token_request.go
- token_revocation.go
- userinfo.go
- verifier_access_token.go
- verifier_id_token_hint.go
- verifier_jwt_profile.go