jwtx

package
v0.0.0-...-66fcd57 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Secret

func Secret(secretKey string) jwt.Keyfunc

Secret 获取秘钥

Types

type Claims

type Claims struct {
	AppID string `json:"appId,omitempty"`
	Uid   string `json:"uid,omitempty"`
	Type  uint   `json:"type,omitempty"` //登录方式
	Role  string `json:"role,omitempty"`
	jwt.RegisteredClaims
}

Claims 结构体,包含 ID 和 Username 字段,以及标准的声明

type Jwt

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

func (Jwt) GenerateToken

func (j Jwt) GenerateToken(uid, role, secretKey string, exp int64) (tokenString string, err error)

GenerateToken 生成token

func (Jwt) ParseToken

func (j Jwt) ParseToken(tokenStr, secretKey string) (*Claims, error)

ParseToken 解析token 并验证是否有效

Jump to

Keyboard shortcuts

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