Documentation ¶
Overview ¶
* @Author: drowningwhale 351231768@qq.com * @Date: 2023-10-01 13:45:12 * @LastEditors: drowningwhale 351231768@qq.com * @LastEditTime: 2023-10-01 19:25:47 * @FilePath: \go-coursed:\Data\Gitee\bluebell\pkg\jwt\jwt.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
Index ¶
Constants ¶
View Source
const TokenExpireDuration = time.Hour * 24 * 30 * 365
Variables ¶
View Source
var CustomSecret = []byte("真爱呀")
CustomSecret 用于加盐的字符串
Functions ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { // 可根据需要自行添加字段 UserID int `json:"user_id"` jwt.RegisteredClaims // 内嵌标准的声明 }
CustomClaims 自定义声明类型 并内嵌jwt.RegisteredClaims jwt包自带的jwt.RegisteredClaims只包含了官方字段 假设我们这里需要额外记录一个username字段,所以要自定义结构体 如果想要保存更多信息,都可以添加到这个结构体中
Click to show internal directories.
Click to hide internal directories.