Documentation
¶
Index ¶
- Constants
- type AuthRequest
- func (a *AuthRequest) Authenticate(deziToken string) error
- func (a AuthRequest) Done() bool
- func (a AuthRequest) GetACR() string
- func (a AuthRequest) GetAMR() []string
- func (a AuthRequest) GetAudience() []string
- func (a AuthRequest) GetAuthTime() time.Time
- func (a AuthRequest) GetClientID() string
- func (a AuthRequest) GetCodeChallenge() *oidc.CodeChallenge
- func (a AuthRequest) GetID() string
- func (a AuthRequest) GetNonce() string
- func (a AuthRequest) GetScopes() []string
- func (a AuthRequest) GetSubject() string
- type Client
- func (c Client) AccessTokenType() op.AccessTokenType
- func (c Client) ApplicationType() op.ApplicationType
- func (c Client) AuthMethod() oidc.AuthMethod
- func (c Client) ClockSkew() time.Duration
- func (c Client) DevMode() bool
- func (c Client) GetID() string
- func (c Client) GrantTypes() []oidc.GrantType
- func (c Client) IDTokenLifetime() time.Duration
- func (c Client) IDTokenUserinfoClaimsAssertion() bool
- func (c Client) IsScopeAllowed(scope string) bool
- func (c Client) LoginURL(authRequestID string) string
- func (c Client) PostLogoutRedirectURIs() []string
- func (c Client) RedirectURIs() []string
- func (c Client) ResponseTypes() []oidc.ResponseType
- func (c Client) RestrictAdditionalAccessTokenScopes() func(scopes []string) []string
- func (c Client) RestrictAdditionalIdTokenScopes() func(scopes []string) []string
- type Component
- type Config
- type PublicKey
- type SigningKey
- type Storage
- func (o Storage) AuthRequestByCode(ctx context.Context, code string) (op.AuthRequest, error)
- func (o Storage) AuthRequestByID(ctx context.Context, id string) (op.AuthRequest, error)
- func (o Storage) AuthenticateUser(ctx context.Context, authRequestID string, deziToken string) error
- func (o Storage) AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string) error
- func (o Storage) CreateAccessAndRefreshTokens(ctx context.Context, request op.TokenRequest, currentRefreshToken string) (accessTokenID string, newRefreshTokenID string, expiration time.Time, ...)
- func (o Storage) CreateAccessToken(ctx context.Context, request op.TokenRequest) (accessTokenID string, expiration time.Time, err error)
- func (o Storage) CreateAuthRequest(ctx context.Context, request *oidc.AuthRequest, userID string) (op.AuthRequest, error)
- func (o Storage) CreateTokenExchangeRequest(ctx context.Context, request op.TokenExchangeRequest) error
- func (o Storage) DeleteAuthRequest(ctx context.Context, id string) error
- func (o Storage) GetClientByClientID(ctx context.Context, clientID string) (op.Client, error)
- func (o Storage) GetKeyByIDAndClientID(ctx context.Context, keyID, clientID string) (*jose.JSONWebKey, error)
- func (o Storage) GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]any, error)
- func (o Storage) GetPrivateClaimsFromTokenExchangeRequest(ctx context.Context, request op.TokenExchangeRequest) (claims map[string]any, err error)
- func (o Storage) GetRefreshTokenInfo(ctx context.Context, clientID string, token string) (userID string, tokenID string, err error)
- func (o Storage) Health(ctx context.Context) error
- func (o Storage) KeySet(ctx context.Context) ([]op.Key, error)
- func (o Storage) RevokeToken(ctx context.Context, tokenOrTokenID string, userID string, clientID string) *oidc.Error
- func (o Storage) SaveAuthCode(ctx context.Context, id string, code string) error
- func (o Storage) SetIntrospectionFromToken(ctx context.Context, userinfo *oidc.IntrospectionResponse, ...) error
- func (o Storage) SetUserinfoFromRequest(ctx context.Context, userinfo *oidc.UserInfo, request op.IDTokenRequest, ...) error
- func (o Storage) SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID, clientID string, ...) error
- func (o Storage) SetUserinfoFromToken(ctx context.Context, userInfo *oidc.UserInfo, tokenID, subject, origin string) error
- func (o Storage) SetUserinfoFromTokenExchangeRequest(ctx context.Context, userinfo *oidc.UserInfo, request op.TokenExchangeRequest) error
- func (o Storage) SignatureAlgorithms(ctx context.Context) ([]jose.SignatureAlgorithm, error)
- func (o Storage) SigningKey(ctx context.Context) (op.SigningKey, error)
- func (o Storage) TerminateSession(ctx context.Context, userID string, clientID string) error
- func (o Storage) TokenRequestByRefreshToken(ctx context.Context, refreshTokenID string) (op.RefreshTokenRequest, error)
- func (o Storage) ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error)
- func (o Storage) ValidateTokenExchangeRequest(ctx context.Context, request op.TokenExchangeRequest) error
- type Token
Constants ¶
const AuthRequestLifetime = 5 * time.Minute
const IDTokenLifetime = time.Hour
IDTokenLifetime defines the lifetime of ID tokens issued to clients. TODO: Adjust this if needed
const TokenLifetime = 5 * time.Minute
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
type AuthRequest struct {
oidc.AuthRequest
ID string
Subject string
DeziToken string
ParsedDeziToken *jwt.Token
AuthTime time.Time
AuthDone bool
Code string
ApplicationID string
ExpirationTime time.Time
}
AuthRequest represents an authentication request in the authorized code flow. It's also used for storage.
func (*AuthRequest) Authenticate ¶
func (a *AuthRequest) Authenticate(deziToken string) error
func (AuthRequest) Done ¶
func (a AuthRequest) Done() bool
func (AuthRequest) GetACR ¶
func (a AuthRequest) GetACR() string
func (AuthRequest) GetAMR ¶
func (a AuthRequest) GetAMR() []string
func (AuthRequest) GetAudience ¶
func (a AuthRequest) GetAudience() []string
func (AuthRequest) GetAuthTime ¶
func (a AuthRequest) GetAuthTime() time.Time
func (AuthRequest) GetClientID ¶
func (a AuthRequest) GetClientID() string
func (AuthRequest) GetCodeChallenge ¶
func (a AuthRequest) GetCodeChallenge() *oidc.CodeChallenge
func (AuthRequest) GetID ¶
func (a AuthRequest) GetID() string
func (AuthRequest) GetNonce ¶
func (a AuthRequest) GetNonce() string
func (AuthRequest) GetScopes ¶
func (a AuthRequest) GetScopes() []string
func (AuthRequest) GetSubject ¶
func (a AuthRequest) GetSubject() string
type Client ¶
type Client struct {
ID string `koanf:"id"`
Secret string `koanf:"secret"`
RedirectURLs []string `koanf:"redirecturls"`
// contains filtered or unexported fields
}
Client represents an OAuth2/OIDC client application. It is used to configure client-specific settings such as redirect URIs, authentication methods, grant types, and token lifetimes.
func (Client) AccessTokenType ¶
func (c Client) AccessTokenType() op.AccessTokenType
func (Client) ApplicationType ¶
func (c Client) ApplicationType() op.ApplicationType
func (Client) AuthMethod ¶
func (c Client) AuthMethod() oidc.AuthMethod
func (Client) GrantTypes ¶
func (Client) IDTokenLifetime ¶
func (Client) IDTokenUserinfoClaimsAssertion ¶
func (Client) IsScopeAllowed ¶
func (Client) PostLogoutRedirectURIs ¶
func (Client) RedirectURIs ¶
func (Client) ResponseTypes ¶
func (c Client) ResponseTypes() []oidc.ResponseType
func (Client) RestrictAdditionalAccessTokenScopes ¶
func (Client) RestrictAdditionalIdTokenScopes ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements an OpenID Connect Provider using the zitadel/oidc library. Since its clients (the EHR) are internal to the Nuts Knooppunt, endpoints intended for the clients are registered on the internal mux. Endpoints intended for end-users (like the authorization endpoint) are registered on the public mux, so they can be accessed through the browser. This also means only confidential clients (clients capable of keeping a secret) are supported (https://oauth.net/2/client-types/).
func New ¶
func New(config Config, httpInterfaces httpComponent.InterfaceInfo, coreConfig core.Config) (*Component, error)
func (*Component) RegisterHttpHandlers ¶
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents a public key that is used for signing ID tokens.
func (PublicKey) Algorithm ¶
func (p PublicKey) Algorithm() jose.SignatureAlgorithm
type SigningKey ¶
type SigningKey struct {
// contains filtered or unexported fields
}
SigningKey represents a key pair that is used to sign ID tokens.
func (SigningKey) ID ¶
func (s SigningKey) ID() string
func (SigningKey) Key ¶
func (s SigningKey) Key() any
func (SigningKey) Public ¶
func (p SigningKey) Public() PublicKey
func (SigningKey) SignatureAlgorithm ¶
func (s SigningKey) SignatureAlgorithm() jose.SignatureAlgorithm
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage implements the op.Storage interface using in-memory maps. TODO: Change to persistent token storage
func (Storage) AuthRequestByCode ¶
func (Storage) AuthRequestByID ¶
func (Storage) AuthenticateUser ¶
func (Storage) AuthorizeClientIDSecret ¶
func (Storage) CreateAccessAndRefreshTokens ¶
func (Storage) CreateAccessToken ¶
func (Storage) CreateAuthRequest ¶
func (o Storage) CreateAuthRequest(ctx context.Context, request *oidc.AuthRequest, userID string) (op.AuthRequest, error)
func (Storage) CreateTokenExchangeRequest ¶
func (Storage) DeleteAuthRequest ¶
func (Storage) GetClientByClientID ¶
func (Storage) GetKeyByIDAndClientID ¶
func (Storage) GetPrivateClaimsFromScopes ¶
func (Storage) GetPrivateClaimsFromTokenExchangeRequest ¶
func (Storage) GetRefreshTokenInfo ¶
func (Storage) RevokeToken ¶
func (Storage) SaveAuthCode ¶
func (Storage) SetIntrospectionFromToken ¶
func (Storage) SetUserinfoFromRequest ¶
func (Storage) SetUserinfoFromScopes ¶
func (o Storage) SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID, clientID string, scopes []string) error
SetUserinfoFromScopes sets the userinfo claims based on the requested scopes and user ID. Since we don't want to store the userinfo in the database, we just return nil here. User info should then be set through SetUserinfoFromRequest