jwt

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

jwt

配置文件增加

JWT_SIGNING_KEY = 签名秘钥 # 默认 gwt_sign_key 类型:string
JWT_SIGNING_METHOD = 加密方式[HS256, HS384, HS512] # 默认 HS256 类型:string
JWT_EXPIRES_TIME = 有效时间 # 默认 10  单位:分钟 类型:int

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SignKey     string = "gwt_sign_key"
	ExpiresTime int    = 259200
)

一些常量

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	Data json.RawMessage
	jwtD.StandardClaims
}

Structured version of Claims Section, as referenced at https://tools.ietf.org/html/rfc7519#section-4.1 See examples for how to use this with your own claim types

type JWT

type JWT struct {
	SigningKey  []byte
	ExpiresTime int64
}

JWT 签名结构

func NewJWT

func NewJWT() *JWT

NewJWT 新建一个jwt实例

func (JWT) CreateToken

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

CreateToken 生成一个token

func (JWT) ParseToken

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

解析Token

func (JWT) RefreshToken

func (j JWT) RefreshToken(tokenString string) (string, error)

更新token

Jump to

Keyboard shortcuts

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