authx

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SecretKey = "1bM1qeHqi33rdiXr9SbrCCmkOeUXTw6vJpzzjhzKmG5g5bhILjOy48pWCpZMCMHU76qZ203KW2tEFNIxTLPxD16AEqEdKWcRznl6"

秘钥

Variables

This section is empty.

Functions

func BuildAuthToken

func BuildAuthToken(param *Param) (string, error)

生成token

func GenerateToken

func GenerateToken(mapClaims jwt.MapClaims, secret string) (string, error)

生成Token值

func GetUserId

func GetUserId(context *gin.Context) (userId int64)

获取用户ID

func ParseTokenToJson

func ParseTokenToJson(token string, secret string) (map[string]interface{}, error)

解析token

Types

type Param

type Param struct {
	UserId     string `json:"userId"`      // 用户ID
	UserName   string `json:"userName"`    // 用户ID
	Phone      string `json:"phone"`       // 登录手机
	LoginIp    string `json:"loginIp"`     // 登录IP
	ExpireTime int64  `json:"sessionTime"` // 到期时间
}

用户token参数

func ParseAuthToken

func ParseAuthToken(token string) (*Param, error)

解析token

Jump to

Keyboard shortcuts

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