jwt

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

@Title @Description @Author Wangwengang 2021/6/5 下午2:16 @Update Wangwengang 2021/6/5 下午2:16

Index

Constants

View Source
const (
	ACCESS_TOKEN_KEY     = "at"    //access_token
	ACCESS_TOKEN_MD5_KEY = "atmd5" // access_token md5
)

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")
	TokenInvalid     = errors.New("Couldn't handle this token:")
	TokenRedisErr    = errors.New("not equal to redis") // redis 校验 唯一登录
)

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	ID         int64  //
	NickName   string //
	BufferTime int64  // 过期设置
	DevUUID    string // 设备uuid
	DevDesc    string // 设备描述
	Platform   string // 平台   android 7  IOS 3

	jwt.StandardClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

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

创建一个token

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string, needRedis bool) (*CustomClaims, error)

解析 token 外部判断tokenString 不能是 ""

func (*JWT) SetAccessToken

func (j *JWT) SetAccessToken(userId int64, tokenString string, ex time.Duration)

Jump to

Keyboard shortcuts

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