jjwt

package
v0.0.0-...-70261f9 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("token 已过期")
	TokenNotValidYet = errors.New("token 无效")
	TokenMalformed   = errors.New("token 格式错误")
	TokenInvalid     = errors.New("token 不可用")
)

Functions

This section is empty.

Types

type JwtClaims

type JwtClaims struct {
	Uid      int      `json:"uid"`
	Username string   `json:"username"`
	Roles    []string `json:"roles"`
	//UserClaims         interface{} //用户信息
	jwt.StandardClaims //标准荷载
}

type JwtToken

type JwtToken struct {
	SigningKey  []byte
	TokenPrefix string
	Issuer      string
}

func (*JwtToken) CreateClaims

func (j *JwtToken) CreateClaims(userId int, username string, roles []string) (string, error)

根据用户登录信息生成token,

func (*JwtToken) ParseTokenByGin

func (j *JwtToken) ParseTokenByGin(c *gin.Context) (*JwtClaims, error)

Jump to

Keyboard shortcuts

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