jwt

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jwt provides functions for generating and validating JWT tokens.

Package jwt provides functions for generating and validating JWT tokens.

Index

Constants

View Source
const ErrInvalidToken = errors.String("invalid token")

Variables

This section is empty.

Functions

func NewTokenSerializer

func NewTokenSerializer(ts ...SerializeSetting) security.TokenSerializer

Types

type Claims

type Claims security.Claims

func (*Claims) GetAudience

func (c *Claims) GetAudience() (jwt.ClaimStrings, error)

func (*Claims) GetExpirationTime

func (c *Claims) GetExpirationTime() (*jwt.NumericDate, error)

func (*Claims) GetIssuedAt

func (c *Claims) GetIssuedAt() (*jwt.NumericDate, error)

func (*Claims) GetIssuer

func (c *Claims) GetIssuer() (string, error)

func (*Claims) GetNotBefore

func (c *Claims) GetNotBefore() (*jwt.NumericDate, error)

func (*Claims) GetSubject

func (c *Claims) GetSubject() (string, error)

type Serialize

type Serialize struct {
	Parser    *jwt.Parser
	Domain    string
	TokenType string
	Expired   time.Duration
	Method    jwt.SigningMethod
	Key       []byte
	OldKey    []byte
	KeyFns    []func(*jwt.Token) (any, error)
}

func (Serialize) Generate

func (s Serialize) Generate(subject string, expires ...time.Duration) security.Token

func (Serialize) Parse

func (s Serialize) Parse(tokenStr string) (security.Token, error)

type SerializeSetting

type SerializeSetting = func(*Serialize)

func WithDomain

func WithDomain(domain string) SerializeSetting

func WithExpired

func WithExpired(expired int) SerializeSetting

func WithKey

func WithKey(key string, keys ...string) SerializeSetting

func WithKeyFns

func WithKeyFns(keyFns ...func(*jwt.Token) (any, error)) SerializeSetting

func WithParser

func WithParser(parser *jwt.Parser) SerializeSetting

func WithSigningMethod

func WithSigningMethod(method jwt.SigningMethod) SerializeSetting

func WithTokenType

func WithTokenType(tokenType string) SerializeSetting

Jump to

Keyboard shortcuts

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