Documentation
¶
Index ¶
- Variables
- type Configuration
- type CouldNotFindKeyForKeyIDError
- type CouldNotUnmarshallResponseError
- type Introspection
- type Provider
- func (p *Provider) Audiences() []string
- func (p *Provider) CustomJWKSURI() string
- func (p *Provider) GetConfiguration(ctx context.Context) (*Configuration, error)
- func (p *Provider) GetSigningKey(ctx context.Context, keyID string) (*jose.JSONWebKey, error)
- func (p *Provider) IntrospectToken(ctx context.Context, token string) (Introspection, error)
- func (p *Provider) Issuer() string
- func (p *Provider) IssuerURI() string
- func (p *Provider) UniqueID() string
- type ProviderOption
- func WithAllowHttpScheme(allowHttpScheme bool) ProviderOption
- func WithCustomIssuerURI(issuerURI string) ProviderOption
- func WithCustomJWKSURI(customJWKSURI string) ProviderOption
- func WithDisableTokenIntrospection(disableTokenIntrospection bool) ProviderOption
- func WithIntrospectQueryParameters(params map[string]string) ProviderOption
- func WithPublicHTTPClient(c *http.Client) ProviderOption
- func WithSecureHTTPClient(c *http.Client) ProviderOption
- type ProviderRespondedNon200Error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidURI = errors.New("invalid URI") ErrInvalidURLScheme = errors.New("invalid URL scheme") ErrCouldNotGetWellKnownConfig = errors.New("could not get well known OpenID configuration") ErrCouldNotBuildURL = errors.New("could not build URL") ErrCouldNotCreateHTTPRequest = errors.New("could not create HTTP request") ErrCouldNotDoHTTPRequest = errors.New("could not do HTTP request") ErrCouldNotReadResponseBody = errors.New("could not read response body") ErrNoIntrospectionEndpoint = errors.New("no introspection endpoint in configuration") ErrTokenIntrospectionDisabled = errors.New("token introspection is disabled") )
var (
DefaultIssuerClaims = []string{"iss"}
)
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct {
Issuer string `json:"issuer,omitempty"`
AuthorizationEndpoint string `json:"authorization_endpoint,omitempty"`
TokenEndpoint string `json:"token_endpoint,omitempty"`
UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"`
JwksURI string `json:"jwks_uri,omitempty"`
ResponseTypesSupported []string `json:"response_types_supported,omitempty"`
GrantTypesSupported []string `json:"grant_types_supported,omitempty"`
SubjectTypesSupported []string `json:"subject_types_supported,omitempty"`
IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported,omitempty"`
ScopesSupported []string `json:"scopes_supported,omitempty"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"`
ClaimsSupported []string `json:"claims_supported,omitempty"`
// From https://datatracker.ietf.org/doc/html/rfc7662
IntrospectionEndpoint string `json:"introspection_endpoint,omitempty"`
// From https://openid.net/specs/openid-connect-rpinitiated-1_0.html#OPMetadata
EndSessionEndpoint string `json:"end_session_endpoint,omitempty"`
}
Configuration is the meta data describing the configuration of an OpenID Provider. It can be onbtained from the .well-known/openid-configuration endpoint. See https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata for details.
type CouldNotFindKeyForKeyIDError ¶
type CouldNotFindKeyForKeyIDError struct {
KeyID string
}
func (CouldNotFindKeyForKeyIDError) Error ¶
func (e CouldNotFindKeyForKeyIDError) Error() string
type CouldNotUnmarshallResponseError ¶
func (CouldNotUnmarshallResponseError) Error ¶
func (e CouldNotUnmarshallResponseError) Error() string
type Introspection ¶
type Introspection struct {
Active bool `json:"active"`
Groups []string `json:"groups,omitempty"`
// Error response fields e.g. bad credentials
Error string `json:"error,omitempty"`
ErrorDescription string `json:"error_description,omitempty"`
}
Introspection represents the response from an introspection request.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func NewProvider ¶
func NewProvider(issuer string, audiences []string, opts ...ProviderOption) (*Provider, error)
NewProvider creates a new provider and applies the given options.
func (*Provider) CustomJWKSURI ¶
func (*Provider) GetConfiguration ¶
func (p *Provider) GetConfiguration(ctx context.Context) (*Configuration, error)
GetConfiguration fetches and stores the OpenID configuration for the provider.
func (*Provider) GetSigningKey ¶
GetSigningKey returns the key for the given key.
func (*Provider) IntrospectToken ¶
IntrospectToken introspects the given token using the OpenID Provider's introspection endpoint.
type ProviderOption ¶
type ProviderOption func(*Provider)
ProviderOption is used to configure a provider.
func WithAllowHttpScheme ¶
func WithAllowHttpScheme(allowHttpScheme bool) ProviderOption
WithAllowHttpScheme configures whether to allow HTTP scheme for URIs. By default, the HTTPS scheme is enforced.
func WithCustomIssuerURI ¶
func WithCustomIssuerURI(issuerURI string) ProviderOption
WithCustomIssuerURI configures a custom issuer URI.
func WithCustomJWKSURI ¶
func WithCustomJWKSURI(customJWKSURI string) ProviderOption
WithCustomJWKSURI configures a custom JWKS URI.
func WithDisableTokenIntrospection ¶
func WithDisableTokenIntrospection(disableTokenIntrospection bool) ProviderOption
WithDisableTokenIntrospection configures whether to disable token introspection.
func WithIntrospectQueryParameters ¶
func WithIntrospectQueryParameters(params map[string]string) ProviderOption
WithIntrospectQueryParameters let's you define addition query parameters to be sent with the introspection request.
func WithPublicHTTPClient ¶
func WithPublicHTTPClient(c *http.Client) ProviderOption
WithPublicHTTPClient let's you set the client to be used for public endpoints, e.g. the well known OpenID configuration endpoint.
func WithSecureHTTPClient ¶
func WithSecureHTTPClient(c *http.Client) ProviderOption
WithSecureHTTPClient let's you set the client to be used for secured endpoints, e.g. the token endpoint.
type ProviderRespondedNon200Error ¶
func (ProviderRespondedNon200Error) Error ¶
func (e ProviderRespondedNon200Error) Error() string