Documentation ¶
Overview ¶
Package fositex contains types and functions for an opinionated Fosite server implementation.
Package fositex provides a wrapper around the fosite library to more easily use the parts that are relevant for us.
Index ¶
- Variables
- func MustViperFlags(v *viper.Viper, flags *pflag.FlagSet)
- func NewOAuth2Provider(configurator *OAuth2Config, store interface{}, strategy interface{}, ...) fosite.OAuth2Provider
- type ClaimMappingStrategy
- type ClaimMappingStrategyProvider
- type Config
- type Factory
- type IssuerJWKSURIProvider
- type OAuth2Config
- func (c *OAuth2Config) GetClaimMappingStrategy(_ context.Context) ClaimMappingStrategy
- func (c *OAuth2Config) GetIssuerJWKSURIProvider(_ context.Context) IssuerJWKSURIProvider
- func (c *OAuth2Config) GetSigningJWKS(_ context.Context) *jose.JSONWebKeySet
- func (c *OAuth2Config) GetSigningKey(_ context.Context) *jose.JSONWebKey
- func (c *OAuth2Config) GetUserInfoAudience() string
- func (c *OAuth2Config) GetUserInfoStrategy(_ context.Context) UserInfoStrategy
- type OAuth2Configurator
- type PrivateKey
- type PrivateKeyType
- type SigningJWKSProvider
- type SigningKeyProvider
- type UserInfoAudienceProvider
- type UserInfoStrategy
- type UserInfoStrategyProvider
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidKey is returned when the key is not valid. ErrInvalidKey = fmt.Errorf("invalid key") )
Functions ¶
func MustViperFlags ¶
MustViperFlags sets the flags needed for Fosite to work.
func NewOAuth2Provider ¶
func NewOAuth2Provider(configurator *OAuth2Config, store interface{}, strategy interface{}, factories ...Factory) fosite.OAuth2Provider
NewOAuth2Provider creates a new fosite.OAuth2Provider. The configurator, store, and strategy are all passed to the factories and the resulting endpoint handlers are registered to the fosite.Config.
Types ¶
type ClaimMappingStrategy ¶
type ClaimMappingStrategy interface {
MapClaims(ctx context.Context, claims *jwt.JWTClaims) (jwt.JWTClaimsContainer, error)
}
ClaimMappingStrategy represents a strategy for mapping token claims to other claims.
type ClaimMappingStrategyProvider ¶
type ClaimMappingStrategyProvider interface {
GetClaimMappingStrategy(ctx context.Context) ClaimMappingStrategy
}
ClaimMappingStrategyProvider represents a provider of a claims mapping strategy.
type Config ¶
type Config struct { Issuer string AccessTokenLifespan int Secret string // When configuring an OAuth provider, the first private key will be used to sign // JWTs. PrivateKeys []PrivateKey }
Config represents an application config section for Fosite.
type Factory ¶ added in v0.0.6
type Factory func(config OAuth2Configurator, store any, strategy any) any
Factory is a constructor which is used to create an OAuth2 endpoin handler. NewOAuth2Provider handles consuming the new struct and attaching it to the parts of the config that it implements.
type IssuerJWKSURIProvider ¶ added in v0.1.1
type IssuerJWKSURIProvider interface {
GetIssuerJWKSURI(ctx context.Context, iss string) (string, error)
}
IssuerJWKSURIProvider represents a provider for the JWKS URI for a given issuer.
type OAuth2Config ¶
type OAuth2Config struct { *fosite.Config SigningKey *jose.JSONWebKey SigningJWKS *jose.JSONWebKeySet ClaimMappingStrategy ClaimMappingStrategy UserInfoStrategy UserInfoStrategy IssuerJWKSURIProvider IssuerJWKSURIProvider // contains filtered or unexported fields }
OAuth2Config represents a Fosite OAuth 2.0 provider configuration.
func NewOAuth2Config ¶
func NewOAuth2Config(config Config) (*OAuth2Config, error)
NewOAuth2Config builds a new OAuth2Config from the given Config.
func (*OAuth2Config) GetClaimMappingStrategy ¶
func (c *OAuth2Config) GetClaimMappingStrategy(_ context.Context) ClaimMappingStrategy
GetClaimMappingStrategy returns the config's claims mapping strategy.
func (*OAuth2Config) GetIssuerJWKSURIProvider ¶ added in v0.1.1
func (c *OAuth2Config) GetIssuerJWKSURIProvider(_ context.Context) IssuerJWKSURIProvider
GetIssuerJWKSURIProvider returns the config's IssuerJWKSURIProvider.
func (*OAuth2Config) GetSigningJWKS ¶
func (c *OAuth2Config) GetSigningJWKS(_ context.Context) *jose.JSONWebKeySet
GetSigningJWKS returns the config's signing JWKS. This includes private keys.
func (*OAuth2Config) GetSigningKey ¶
func (c *OAuth2Config) GetSigningKey(_ context.Context) *jose.JSONWebKey
GetSigningKey returns the config's signing key.
func (*OAuth2Config) GetUserInfoAudience ¶ added in v0.1.0
func (c *OAuth2Config) GetUserInfoAudience() string
GetUserInfoAudience returns this services userinfo audience.
func (*OAuth2Config) GetUserInfoStrategy ¶
func (c *OAuth2Config) GetUserInfoStrategy(_ context.Context) UserInfoStrategy
GetUserInfoStrategy returns the config's user info store strategy.
type OAuth2Configurator ¶
type OAuth2Configurator interface { fosite.Configurator SigningKeyProvider SigningJWKSProvider ClaimMappingStrategyProvider UserInfoStrategyProvider GetIssuerJWKSURIProvider(ctx context.Context) IssuerJWKSURIProvider }
OAuth2Configurator represents an OAuth2 configuration.
type PrivateKey ¶
type PrivateKey struct { KeyID string Algorithm jose.SignatureAlgorithm Path string }
PrivateKey represents a path to a private key on disk with a given key ID.
type PrivateKeyType ¶
type PrivateKeyType string
PrivateKeyType represents a key type (public or symmetric)
const ( // PrivateKeyTypePublic represents a public key type. PrivateKeyTypePublic PrivateKeyType = "public" // PrivateKeyTypeSymmetric represents a symmetric key type. PrivateKeyTypeSymmetric PrivateKeyType = "symmetric" )
type SigningJWKSProvider ¶
type SigningJWKSProvider interface {
GetSigningJWKS(ctx context.Context) *jose.JSONWebKeySet
}
SigningJWKSProvider represents a provider of a valid signing JWKS.
type SigningKeyProvider ¶
type SigningKeyProvider interface {
GetSigningKey(ctx context.Context) *jose.JSONWebKey
}
SigningKeyProvider represents a provider of a signing key.
type UserInfoAudienceProvider ¶ added in v0.1.0
type UserInfoAudienceProvider interface { // GetUserInfoAudience returns the audience for the identity-api issuer GetUserInfoAudience() string }
UserInfoAudienceProvider returns the user info audience to attach to tokens
type UserInfoStrategy ¶
type UserInfoStrategy interface { types.UserInfoService }
UserInfoStrategy persists user information in the storage backend.
type UserInfoStrategyProvider ¶
type UserInfoStrategyProvider interface {
GetUserInfoStrategy(ctx context.Context) UserInfoStrategy
}
UserInfoStrategyProvider represents the provider of the UserInfoStrategy.