jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERPROFIX = "jwt_" // version前缀
)

Variables

View Source
var (
	JWTSECRET  = "7KCQC8YW3AMF7A98OIUV2Q6MEKE3GTGSYB3RFWI89KS071URZ2MJDPZKTJIUVZUY"
	TokenTerm  = time.Hour * 24
	VersionCtl = false // 开启版本控制
)

todo 配置

View Source
var JWT_STATUS = map[int]string{
	200: "OK",
	400: "Token is required",
	401: "Token verification failed",
	504: "Token verification timeout",
}

Functions

func Auth

func Auth() gin.HandlerFunc

验证JWT的中间件 从Http头部的Authorization(忽略大小写)中获取Token信息,并验证Token的有效性。

func Generate

func Generate(uuid string) (string, error)

生成JWT令牌: uuid :用户唯一标识,

Types

type Claims

type Claims struct {
	jwt.StandardClaims       // 标准Claim
	Ver                int64 // 服务端版本号
}

func Verify

func Verify(token string) (*Claims, error)

将Token字符串解析成Claim对象

Jump to

Keyboard shortcuts

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