jwt

package
v2.0.0-beta14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SecretKey string        `koanf:"SecretKey"` // Secret key for signing the token, required. The key should match the algorithm.
	Algorithm string        `koanf:"Algorithm"` // Algorithm of the token, default is HS256. Supported algorithms: HS256, HS384, HS512
	Expire    time.Duration `koanf:"Expire"`    // Expire time of the token, default is 24 hours
}

type Manager

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

func New

func New(cfg Config) *Manager

func (*Manager) Generate

func (m *Manager) Generate(userID uint) (string, string, error)

Generate generates a JWT token for the given user ID. It returns the token and the id of the token.

func (*Manager) Parse

func (m *Manager) Parse(token string) (jwt.Claims, error)

Parser parses the JWT token and returns the claims.

Jump to

Keyboard shortcuts

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