jwks

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKIDNotFound = keyfunc.ErrKIDNotFound

Functions

func GetOptionJWK

func GetOptionJWK(opts ...OptionJWK) optionsJWK

func MapOptionKeyfunc

func MapOptionKeyfunc(opt optionsJWK) keyfunc.Options

func MultiJWTKeyFunc

func MultiJWTKeyFunc(providers []InfProvider, opts ...OptionJWK) (models.InfKeyFunc, error)

MultiJWTKeyFunc returns a jwt.Keyfunc with multiple keyfunc.

Doesn't support introspect and noops, it will ignore them.

Types

type InfProvider

type InfProvider interface {
	GetCertURL() string
	IsNoop() bool
}

type KeyFuncMulti

type KeyFuncMulti struct {
	// contains filtered or unexported fields
}

func (*KeyFuncMulti) KeySelectorFirst

func (k *KeyFuncMulti) KeySelectorFirst(multiJWKS *keyfunc.MultipleJWKS, token *jwt.Token) (interface{}, error)

func (*KeyFuncMulti) Keyfunc

func (k *KeyFuncMulti) Keyfunc(token *jwt.Token) (interface{}, error)

type KeyFuncParser

type KeyFuncParser struct {
	KeyFunc func(token *jwt.Token) (interface{}, error)
}

func (*KeyFuncParser) Keyfunc

func (j *KeyFuncParser) Keyfunc(token *jwt.Token) (interface{}, error)

func (*KeyFuncParser) ParseWithClaims

func (j *KeyFuncParser) ParseWithClaims(tokenString string, claims jwt.Claims) (*jwt.Token, error)

type OptionJWK

type OptionJWK func(options *optionsJWK)

func WithClient

func WithClient(client *http.Client) OptionJWK

WithClient is used to set the http.Client used to fetch the JWKs.

func WithContext

func WithContext(ctx context.Context) OptionJWK

WithContext is used to set the context used to fetch the JWKs.

func WithIntrospect

func WithIntrospect(v bool) OptionJWK

func WithKeyFunc

func WithKeyFunc(keyFunc models.InfKeyFunc) OptionJWK

WithGivenKeys is used to set the given keys used to verify the token.

Return ErrKIDNotFound if the kid is not found.

Example:

// Create the JWKS from the given keys.
givenKeys := map[string]keyfunc.GivenKey{
	"my-key-id": keyfunc.NewGivenHMAC(...),
}
jwks := keyfunc.NewGiven(givenKeys)

func WithRefreshErrorHandler

func WithRefreshErrorHandler(fn func(err error)) OptionJWK

WithRefreshErrorHandler sets the refresh error handler for the jwt.Key.

func WithRefreshInterval

func WithRefreshInterval(d time.Duration) OptionJWK

WithRefreshInterval sets the refresh interval for the jwt.Keyfunc default is 5 minutes.

Jump to

Keyboard shortcuts

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