jwp

package
v1.1.34 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidClaims = errors.New("invalid claims")

Functions

This section is empty.

Types

type ClaimsCheck added in v1.1.0

type ClaimsCheck interface {
	CheckClaims(claims *jwa.Claims) error
}

type ClaimsCheckTarget added in v1.1.0

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

func NewClaimsCheckTarget added in v1.1.0

func NewClaimsCheckTarget(target jwt.TargetConfig) *ClaimsCheckTarget

func (*ClaimsCheckTarget) CheckClaims added in v1.1.0

func (claimsCheck *ClaimsCheckTarget) CheckClaims(claims *jwa.Claims) error

type ClaimsCheckTimestamp added in v1.1.0

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

func NewClaimsCheckTimestamp added in v1.1.0

func NewClaimsCheckTimestamp(leeway time.Duration, requireExp bool) *ClaimsCheckTimestamp

func (*ClaimsCheckTimestamp) CheckClaims added in v1.1.0

func (claimsCheck *ClaimsCheckTimestamp) CheckClaims(claims *jwa.Claims) error

type ClaimsChecker

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

func NewClaimsChecker

func NewClaimsChecker(config *ClaimsCheckerConfig) *ClaimsChecker

NewClaimsChecker is a custom claims unmarshaler, that performs extra checks on the claims.

func (*ClaimsChecker) Unmarshal

func (checker *ClaimsChecker) Unmarshal(raw []byte, dst any) error

type ClaimsCheckerConfig

type ClaimsCheckerConfig struct {
	Checks    []ClaimsCheck
	ChecksRaw []RawClaimsCheck

	// Set a custom deserializer to decode the token's payload. Uses json.Unmarshal by default.
	Deserializer func(raw []byte, dst any) error
}

type EmbedKey

type EmbedKey[K any] struct {
	// contains filtered or unexported fields
}

func NewEmbedKey

func NewEmbedKey[K any](config EmbedKeyConfig[K]) *EmbedKey[K]

NewEmbedKey is a plugin that embeds a key in the header of a token. You can use this as a jwt.ProducerStaticPlugin.

func (*EmbedKey[K]) Header

func (plugin *EmbedKey[K]) Header(ctx context.Context, header *jwa.JWH) (*jwa.JWH, error)

type EmbedKeyConfig

type EmbedKeyConfig[K any] struct {
	// Source to get the key from. Optional, overrides Key if set.
	Source *jwk.Source[K]
	// JSON Web Key to embed. This is optional, and is overridden by Source if set.
	Key *jwa.JWK
	// ID of the key. If a Source is set, it will be used to retrieve the specific key.
	// If not provided, this parameter is automatically set using Key or Source, if present.
	KID string
	// URL to retrieve the key from. Optional.
	URL string
	// Embed the key. By default, only the KID is provided to save space. If this parameter is used, and a key is
	// provided, it will be fully embedded in the header.
	Embed bool
}

type RawClaimsCheck added in v1.1.0

type RawClaimsCheck interface {
	CheckRaw(raw []byte) error
}

type RawClaimsChecker added in v1.1.0

type RawClaimsChecker[T any] struct {
	// contains filtered or unexported fields
}

func NewRawClaimsChecker added in v1.1.0

func NewRawClaimsChecker[T any](config T, callback func(raw []byte, config T) error) *RawClaimsChecker[T]

func (*RawClaimsChecker[T]) CheckRaw added in v1.1.0

func (claimsCheck *RawClaimsChecker[T]) CheckRaw(raw []byte) error

Jump to

Keyboard shortcuts

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