jwt

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

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")
)

一些常量

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	UserID string `json:"user_id"`
	jwt.StandardClaims
}

CustomClaims 用于构成payload

type JwtSign

type JwtSign struct {
	SigningKey []byte
}

JwtSign 结构体

func NewJwtSign

func NewJwtSign(jwtSecret string) *JwtSign

新建一个JwtSign实例

func (*JwtSign) CreateToken

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

CreateToken 生成一个token

func (*JwtSign) GetClaimsFromExpiredToken

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

GetClaimsFromExpiredToken 从一个过期的token中获取claims

func (*JwtSign) ParseToken

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

ParseToken 解析一个token

Jump to

Keyboard shortcuts

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