my_jwt

package
v0.0.0-...-9f75418 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSignKey

func GetSignKey() string

获取signKey

func SetSignKey

func SetSignKey(key string) string

设置signKey(类似秘钥)

Types

type CustomClaims

type CustomClaims struct {
	UserId int64  `form:"userid" json:"userid"`
	Name   string `form:"user_name" json:"user_name"`
	Phone  string `form:"phone" json:"phone"`
	jwt.StandardClaims
}

自定义jwt的声明字段信息+标准字段,参考地址:https://blog.csdn.net/codeSquare/article/details/99288718

type JwtSign

type JwtSign struct {
	SigningKey []byte
}

定义一个 JWT验签 结构体

func CreateMyJWT

func CreateMyJWT(signKey string) *JwtSign

使用工厂创建一个 JWT 结构体

func (*JwtSign) CreateToken

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

CreateToken 生成一个token

func (*JwtSign) ParseToken

func (j *JwtSign) ParseToken(tokenString string) (*CustomClaims, error)

解析Token

func (*JwtSign) RefreshToken

func (j *JwtSign) RefreshToken(tokenString string, extraAddSeconds int64) (string, error)

更新token

Jump to

Keyboard shortcuts

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