jwt

package
v1.186.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	// Identifies the principal that issued the JWT.
	Issuer string

	// Identifies the principal that is the subject of the JWT.
	Subject string

	// Identifies the recipients that the JWT is intended for.
	Audience string

	// Identifies the expiration time on or after which the JWT MUST NOT be accepted
	// for processing.
	Expiry time.Time

	// Identifies the time before which the JWT MUST NOT be accepted for processing.
	//
	// It is optional.
	NotBefore time.Time

	// Identifies the time at which the JWT was issued.
	//
	// It is optional, as it will be filled with the current timestamp when signing.
	IssuedAt time.Time
}

func (*Claims) SetSubjectInt

func (claims *Claims) SetSubjectInt(subject int64)

func (Claims) SubjectInt

func (claims Claims) SubjectInt() int64

type CustomClaims

type CustomClaims struct{}

type CustomClaimsImplementation

type CustomClaimsImplementation interface {
	// contains filtered or unexported methods
}

type Expected

type Expected struct {
	// Expected principal that issued the JWT.
	Issuer string

	// Expected audience for the token in case it is intended for another use.
	Audience string
}

type Generator

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

func NewHS256

func NewHS256(key string) *Generator

func NewHS256Base64 added in v1.75.0

func NewHS256Base64(encodedKey string) *Generator

func NewRS256FromWellKnown added in v1.78.0

func NewRS256FromWellKnown(wkurl string) *Generator

NewRS256FromWellKnown prepares a generator that only reads signed JWTs verifying them with the cached keys obtained from the well known URL.

The well known URL is something like this:

https://{domain}/.well-known/jwks.json

func (*Generator) Close added in v1.78.0

func (g *Generator) Close()

func (*Generator) Extract

func (g *Generator) Extract(token string, expected Expected, claims *Claims, customs ...CustomClaimsImplementation) error

func (*Generator) Sign

func (g *Generator) Sign(claims Claims, customs ...CustomClaimsImplementation) (string, error)

type InvalidTokenError

type InvalidTokenError struct {
	Reason string
}

func (*InvalidTokenError) Error

func (err *InvalidTokenError) Error() string

Jump to

Keyboard shortcuts

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