jwt

package
v2.0.0-...-96525d9 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingKID is returned by Authenticate Strategy method,
	// when failed to retrieve kid from token header.
	ErrMissingKID = errors.New("Token missing " + headerKID + " header")

	// ErrInvalidAlg is returned by Authenticate Strategy method,
	// when jwt token alg header does not match key algorithm.
	ErrInvalidAlg = errors.New("Invalid signing algorithm, token alg header does not match key algorithm")
)

Functions

func IssueToken

func IssueToken(k SecretsKeeper, dest ...interface{}) (string, error)

IssueToken issue jwt access token from the given dest.

func ParseToken

func ParseToken(k SecretsKeeper, token string, dest ...interface{}) error

ParseToken parse jwt access token to the given dest.

Types

type SecretsKeeper

type SecretsKeeper interface {
	// KID return's secret/key id.
	// KID must return the most recently used id if more than one secret/key exists.
	// https://tools.ietf.org/html/rfc7515#section-4.1.4
	KID() string
	// Get return's secret/key and the corresponding sign algorithm.
	Get(kid string) (key interface{}, algorithm string, err error)
}

SecretsKeeper hold all secrets/keys to sign and parse JWT token

Jump to

Keyboard shortcuts

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