jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

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

func New

func New(log *zap.Logger, authorities map[string]Authority) *Authenticator

func (Authenticator) Authenticate

func (a Authenticator) Authenticate(ctx context.Context, tokenStr string) (*auth.Customer, error)

Authenticate takes a JWT and returns an authenticated auth.Customer

func (Authenticator) CanAccept

func (a Authenticator) CanAccept(token string) bool

CanAccept returns true if the token can be handled by this Authenticator. This does not confirm the token is a valid JWT, just that there 3 base64url strings separated by periods.

type Authority

type Authority interface {
	// JWK takes a kid from a JWT and returns a matching JWK
	JWK(kid string) (jwk.Key, bool)
	// NewCustomerClaims returns a pointer to an implementation of CustomerClaims
	NewCustomerClaims() CustomerClaims
}

Authority represents a JWT Authority that can validate the token and define the customer claims.

type CustomerClaims

type CustomerClaims interface {
	// Customer returns the customer built from custom claims.
	Customer() *auth.Customer
	jwt.Claims
}

CustomerClaims represents a struct that JWT claims can be unmarshalled into. As well as the standard registered claims, there should also be customer claims that represent the authenticated auth.Customer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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