Documentation
¶
Index ¶
- Constants
- Variables
- func AddAddressClaims(claims map[string]any, user User)
- func AddEmailClaims(claims map[string]any, user User)
- func AddExtraClaims(claims map[string]any, extraClaims map[string]string, user User, ...)
- func AddPhoneClaims(claims map[string]any, user User)
- func AddProfileClaims(claims map[string]any, user User)
- func AuthorizeHandler(basePath string, tokenService TokenCreator, ...) http.Handler
- func DiscoveryDocumentHandler(issuer, scope string, tokenRevocationSupported bool) http.Handler
- func Error(w http.ResponseWriter, error string, description string, code int)
- func IntersectScope(availableScope, requestedScope string) string
- func JwksHandler(keySetProvider keyset.Provider) http.Handler
- func NewTokenID(timestamp time.Time) string
- func RevokeHandler(tokenCreator TokenCreator, clientStore clients.Store, ...) http.Handler
- func ToJwks(publicKeys map[string]any) []jose.JSONWebKey
- func TokenHandler(tokenService TokenCreator, peopleStore people.Store, clientStore clients.Store, ...) http.Handler
- func UserinfoHandler(peopleStore people.Store, extraClaims map[string]string, ...) http.Handler
- type DiscoveryDocument
- type ErrorResponse
- type RoleMapping
- type RoleMappings
- type TokenCreator
- type TokenResponse
- type User
- type VerifiedClaims
Constants ¶
View Source
const ( ClaimClientID = "cid" ClaimExpiryTime = "exp" ClaimIssuer = "iss" ClaimIssuedAtTime = "iat" ClaimNotBeforeTime = "nbf" ClaimUserID = "uid" ClaimScope = "scope" ClaimSubject = "sub" ClaimType = "typ" ClaimAudience = "aud" ClaimAccessTokenHash = "at_hash" ClaimNonce = "nonce" ClaimTokenID = "jti" )
View Source
const ( // ErrorInvalidRequest - The request is missing a parameter so the server // can't proceed with the request. This may also be returned if the // request includes an unsupported parameter or repeats a parameter. ErrorInvalidRequest = "invalid_request" // ErrorInvalidClient – Client authentication failed, such as if the // request contains an invalid client ID or secret. Send an HTTP 401 // response in this case. ErrorInvalidClient = "invalid_client" // ErrorInvalidGrant – The authorization code (or user's password for the // password grant type) is invalid or expired. This is also the error you // would return if the redirect URL given in the authorization grant does // not match the URL provided in this access token request. ErrorInvalidGrant = "invalid_grant" // ErrorRedirectURIMismatch - The redirect URI is invalid for the // requested client id ErrorRedirectURIMismatch = "redirect_uri_mismatch" // ErrorUnsupportedGrantType – If a grant type is requested that the // authorization server doesn't recognize, use this code. Note that // unknown grant types also use this specific error code rather than using // the ErrorInvalidRequest above. ErrorUnsupportedGrantType = "unsupported_grant_type" ErrorInternal = "internal_server_error" ErrorNotFound = "not_found" )
View Source
const ( GrantTypeAuthorizationCode = "authorization_code" GrantTypeClientCredentials = "client_credentials" GrantTypeRefreshToken = "refresh_token" GrantTypePassword = "password" TokenTypeCode = "code" TokenTypeRefresh = "refresh" TokenTypePasswordReset = "passwd" ResponseTypeCode = "code" ResponseTypeToken = "token" )
View Source
const OIDCDefaultScope = "openid profile email phone address offline_access"
Variables ¶
View Source
var ( ErrInvalidTokenType = errors.New("invalid token type (typ)") ErrUnsupportedAlgorithm = errors.New("unsupported token signing algorithm") )
Functions ¶
func AddAddressClaims ¶
func AddEmailClaims ¶
func AddExtraClaims ¶
func AddPhoneClaims ¶
func AddProfileClaims ¶
func AuthorizeHandler ¶
func IntersectScope ¶
func NewTokenID ¶
func RevokeHandler ¶
func RevokeHandler(tokenCreator TokenCreator, clientStore clients.Store, revocationStore revocation.Store) http.Handler
func ToJwks ¶
func ToJwks(publicKeys map[string]any) []jose.JSONWebKey
ToJwks creates JSON Web Keys from multiple public keys
func TokenHandler ¶
func UserinfoHandler ¶ added in v0.8.0
Types ¶
type DiscoveryDocument ¶
type DiscoveryDocument struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
JwksURI string `json:"jwks_uri"`
ResponseTypesSupported []string `json:"response_types_supported"`
GrantTypesSupported []string `json:"grant_types_supported"`
TokenEndpoint string `json:"token_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
EndSessionEndpoint string `json:"end_session_endpoint"`
ScopesSupported []string `json:"scopes_supported"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported,omitempty"`
IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported"`
RevocationEndpoint string `json:"revocation_endpoint,omitempty"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"`
}
type ErrorResponse ¶
type RoleMapping ¶
type RoleMappings ¶
type RoleMappings map[string]RoleMapping
func (RoleMappings) ClientRoles ¶ added in v0.8.0
func (c RoleMappings) ClientRoles(clientID string) []string
func (RoleMappings) Roles ¶
func (c RoleMappings) Roles(user User) []string
type TokenCreator ¶
type TokenCreator interface {
GenerateAccessToken(user User, presetID, subject, clientID, scope string) (string, error)
GenerateIDToken(user User, presetID, clientID, scope, accessTokenHash, nonce string) (string, error)
GenerateAuthCode(presetID, userID, clientID, scope, challenge, nonce string) (string, error)
GeneratePasswordResetToken(presetID, userID, clientID string) (string, error)
GenerateRefreshToken(presetID, userID, clientID, scope, nonce string) (string, error)
Verify(rawToken, tokenType string) (*VerifiedClaims, error)
Issuer() string
}
func NewTokenCreator ¶
func NewTokenCreator(privateKey *rsa.PrivateKey, keyID, issuer, scope string, presets presets.Presets, roleMappings RoleMappings) (TokenCreator, error)
type TokenResponse ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.