jwt

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGNING_KEY string        = "dl-jwt-key"
	EXPIRE_TIME time.Duration = 24 // 过期时间24小时
	ISSUER      string        = "lrobin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClaims

type BaseClaims struct {
	ID    uint
	Email string
	IP    string
}

type Claims

type Claims struct {
	BaseClaims
	jwt.RegisteredClaims
}

Custom claims structure

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT(signingKey string) *JWT

func (*JWT) CreateClaims

func (j *JWT) CreateClaims(baseClaims BaseClaims, expiresTime int64, issuer string) Claims

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims Claims) (string, error)

创建一个token

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*Claims, error)

解析 token

Jump to

Keyboard shortcuts

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