token

package
v0.0.0-...-b971483 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(userName, userID, perAddr string, roles []string, issuer string, expireTime int64) (string, error)

Encode 将 User 用户信息加密为 JWT 字符串 expireTime := time.Now().Add(time.Hour * 24 * 3).Unix() 三天后过期

func InitConfig

func InitConfig(filePath string, path ...string)

InitConfig 初始化

Types

type CustomClaims

type CustomClaims struct {
	UserName string   `json:"user_name"`
	UserID   string   `json:"user_id"`
	PerAddr  string   `json:"per_addr"`
	Roles    []string `json:"roles"`

	jwt.StandardClaims
}

CustomClaims 自定义的 metadata在加密后作为 JWT 的第二部分返回给客户端

func Decode

func Decode(tokenStr string) (*CustomClaims, error)

Decode 解码

Jump to

Keyboard shortcuts

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