Documentation
¶
Overview ¶
用户认证 ( authentication ) 与授权 ( authorization ) 模块 通证 ( Token ) 相关。
通证 ( Token ): 当客户端用户登陆成功后,系统会向该客户端用户签发一定有效期的 token,之后客户端用户每次请求的时候,都需要在请求头部携带该 token, 以标示自己的用户身份。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var SMSLogin *smsLogin
Functions ¶
Types ¶
type TokenUser ¶
type TokenUser struct {
// 用户 ID
ID int64 `json:"i"`
// Token 失效时间
ExpiresAt int64 `json:"e"`
// 用户角色
Roles []int64 `json:"r"`
// 用户权限
Perms []int64 `json:"p"`
Settings int64 `json:"s"`
}
TokenUser: 编码在 token 字符串中的用户信息
func ExtractTokenUser ¶
http.Request 中解析 TokenUser
func NewTokenUser ¶
从 models.User 获得 TokenUser
Click to show internal directories.
Click to hide internal directories.