jwt

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorMessage_ValidationErrorMalformed   = "无效token"
	ErrorMessage_ValidationErrorExpired     = "token已过期"
	ErrorMessage_ValidationErrorNotValidYet = "token未激活"
)

Variables

View Source
var (
	//KeyTokenClaim token写入gin.context的名称
	KeyTokenClaim = "token-claims"
)

Functions

func EncryToken

func EncryToken(user TokenUserInput, secretKey string) (r string, err error)

EncryToken 创建jwt-token

func Middleware

func Middleware(tokenName string, secretKey string) gin.HandlerFunc

Middleware token校验中间件

Types

type SgcClaims

type SgcClaims struct {
	ID       int64  `json:"Id"`
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

SgcClaims 继承jwt.StandardClaims

func DecrypToken

func DecrypToken(token string, secretKey string) (claims *SgcClaims, err error)

DecrypToken 解析jwt-token

type TokenUserInput

type TokenUserInput struct {
	ID       int64  `json:"Id"`
	Username string `json:"username"`
	Password string `json:"password"`
	//按秒计算
	Expire int64 `json:"expire"`
}

TokenUserInput 生成token的输入参数

Jump to

Keyboard shortcuts

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