fositex

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKey is returned when the key is not valid.
	ErrInvalidKey = fmt.Errorf("invalid key")
)

Functions

func MustViperFlags

func MustViperFlags(v *viper.Viper, flags *pflag.FlagSet, defaultListen string)

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 IssuerJWKSURIStrategy

type IssuerJWKSURIStrategy interface {
	GetIssuerJWKSURI(ctx context.Context, iss string) (string, error)
}

IssuerJWKSURIStrategy represents a strategy for getting the JWKS URI for a given issuer.

type IssuerJWKSURIStrategyProvider

type IssuerJWKSURIStrategyProvider interface {
	GetIssuerJWKSURIStrategy(ctx context.Context) IssuerJWKSURIStrategy
}

IssuerJWKSURIStrategyProvider represents a provider for a IssuerJWKSURIStrategy.

type OAuth2Config

type OAuth2Config struct {
	*fosite.Config
	SigningKey            *jose.JSONWebKey
	SigningJWKS           *jose.JSONWebKeySet
	IssuerJWKSURIStrategy IssuerJWKSURIStrategy
	ClaimMappingStrategy  ClaimMappingStrategy
	UserInfoStrategy      UserInfoStrategy
}

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(ctx context.Context) ClaimMappingStrategy

GetClaimMappingStrategy returns the config's claims mapping strategy.

func (*OAuth2Config) GetIssuerJWKSURIStrategy

func (c *OAuth2Config) GetIssuerJWKSURIStrategy(ctx context.Context) IssuerJWKSURIStrategy

GetIssuerJWKSURIStrategy returns the config's IssuerJWKSURIStrategy.

func (*OAuth2Config) GetSigningJWKS

func (c *OAuth2Config) GetSigningJWKS(ctx context.Context) *jose.JSONWebKeySet

GetSigningJWKS returns the config's signing JWKS. This includes private keys.

func (*OAuth2Config) GetSigningKey

func (c *OAuth2Config) GetSigningKey(ctx context.Context) *jose.JSONWebKey

GetSigningKey returns the config's signing key.

func (*OAuth2Config) GetUserInfoStrategy

func (c *OAuth2Config) GetUserInfoStrategy(ctx context.Context) UserInfoStrategy

GetUserInfoStrategy returns the config's user info store strategy.

type OAuth2Configurator

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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL