jwt

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyKey when key is empty.
	ErrEmptyKey = errors.New("empty sign key")
	// ErrTokenInvalid when token has expired or has invalid data.
	ErrTokenInvalid = errors.New("invalid token")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	SigningKey    string
	SigningMethod libjwt.SigningMethod
	KeyFunc       libjwt.Keyfunc
}

Config defines the config for JWT tokens.

func NewJWTConfig

func NewJWTConfig(key string) Config

NewJWTConfig creates an instance of a default jwt config.

func (Config) GenerateToken

func (c Config) GenerateToken(claims map[string]interface{}) (string, error)

GenerateToken generates a JWT token for given config and claims.

func (Config) ValidateToken

func (c Config) ValidateToken(tokenString string) error

ValidateToken returns whether given token is valid or not for configuration.

Jump to

Keyboard shortcuts

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