jwt

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSecretKey = errors.New("invalid secret key")
	ErrInvalidType      = errors.New("invalid type")
)

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims[T comparable] struct {
	SignInfo T
	jwt.RegisteredClaims
}

type JWT

type JWT[T comparable] struct {
	// contains filtered or unexported fields
}

func NewES256JWT

func NewES256JWT[T comparable](secretKey *ecdsa.PrivateKey) (*JWT[T], error)

func NewHS256JWT

func NewHS256JWT[T comparable](secretKey []byte) (*JWT[T], error)

func NewJWT

func NewJWT[T comparable](secretKey any, signingAlgo jwt.SigningMethod) (*JWT[T], error)

func (*JWT[T]) CreateDefaultToken

func (j *JWT[T]) CreateDefaultToken(signInfo T, expiresAt time.Time) (string, error)

func (*JWT[T]) CreateToken

func (j *JWT[T]) CreateToken(claims CustomClaims[T]) (string, error)

func (*JWT[T]) ParseToken

func (j *JWT[T]) ParseToken(tokenString string) (*CustomClaims[T], error)

func (*JWT[T]) ParseTokenWithKeyFunc

func (j *JWT[T]) ParseTokenWithKeyFunc(tokenString string, keyFunc func(signingAlgo jwt.SigningMethod, secretKey any, token *jwt.Token) (any, error)) (*CustomClaims[T], error)

func (*JWT[T]) VerifyToken

func (j *JWT[T]) VerifyToken(tokenString string, claims CustomClaims[T]) error

func (*JWT[T]) VerifyTokenOnlySignInfo

func (j *JWT[T]) VerifyTokenOnlySignInfo(tokenString string, signInfo T) error

Jump to

Keyboard shortcuts

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