jwt

package
v0.0.0-...-d5572aa Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 5 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 {
	Data []byte `json:"data,omitempty"`
	jwt.RegisteredClaims
}

type Manager

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

func NewManager

func NewManager[T any](secret string, tokenTTL time.Duration) *Manager[T]

func (Manager[T]) GenerateToken

func (m Manager[T]) GenerateToken(payload T) (string, error)

GenerateToken generates a JWT token with a given payload.

func (Manager[T]) ValidateToken

func (m Manager[T]) ValidateToken(tokenString string) (T, error)

ValidateToken validates the given JWT token and returns a payload.

type TokenManager

type TokenManager[T any] interface {
	GenerateToken(payload T) (string, error)
	ValidateToken(tokenString string) (T, error)
}

Jump to

Keyboard shortcuts

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