jwt

package
v0.0.0-...-6f9dc6e Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrToken             = errors.Unauthorized(reason, "JWT token error")
	ErrMissingJwtToken   = errors.Unauthorized(reason, "JWT token is missing")
	ErrExpiredOrNotValid = errors.Unauthorized(reason, "JWT token expire or not valid")
)

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	jwt.RegisteredClaims
}

CustomClaims 自定义 claims

type TokenGen

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

TokenGen 生成

func NewJwtTokenGen

func NewJwtTokenGen(issuer string, signKey []byte) *TokenGen

func (*TokenGen) GenerateToken

func (t *TokenGen) GenerateToken(id uint64, expireSec time.Duration) (string, error)

GenerateToken 生成 token

type TokenValidator

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

TokenValidator token 校验

func NewTokenValidator

func NewTokenValidator(signKey []byte) *TokenValidator

func (*TokenValidator) Validator

func (v *TokenValidator) Validator(token string, options ...jwt.ParserOption) (uint64, error)

Validator 校验 token

Jump to

Keyboard shortcuts

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