jwtauth

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenUnexpectedSigningMethod = errors.New("unexpected signing method")
	ErrTokenInvalid                 = errors.New("invalid token")
	ErrAudienceUnknown              = errors.New("unknown audience")
	ErrSubjectUnknown               = errors.New("unknown subject")
	ErrMissingScopes                = errors.New("missing scopes")
	ErrTokenExpired                 = errors.New("token expired")
)

Functions

This section is empty.

Types

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(key crypto.PublicKey, options Options) Authorizer

func (Authorizer) Authorize

func (a Authorizer) Authorize(claims *Claims, scopes ...string) error

func (Authorizer) Validate

func (a Authorizer) Validate(tokenStr string) (*Claims, error)

type Claims

type Claims struct {
	jwt.RegisteredClaims
	ClientID string   `json:"client_id"`
	Scopes   []string `json:"scopes"`
}

type Issuer

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

func NewIssuer

func NewIssuer(key crypto.PrivateKey, options Options) *Issuer

func (Issuer) CreateToken

func (i Issuer) CreateToken(ttl time.Duration, scopes ...string) *Claims

func (Issuer) Sign

func (i Issuer) Sign(claims *Claims) (string, error)

type Options

type Options struct {
	// if Issuer is empty, all issuers are allowed
	Issuer string
	// if Subject is empty, all subjects are allowed
	Subject string
	// if Audience is empty, all audiences are allowed
	Audience []string

	SigningMethod jwt.SigningMethod

	ClientID string
}

Jump to

Keyboard shortcuts

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