Documentation ¶
Index ¶
Constants ¶
View Source
const (
AuthBearer = "Bearer "
)
Variables ¶
View Source
var ( // ErrInvalidAudience 无效的audience ErrInvalidAudience = errors.New("invalid audience") // ErrInvalidLoginWay 无效的登录方式 ErrInvalidLoginWay = errors.New("invalid login way") )
Functions ¶
This section is empty.
Types ¶
type InjectorFunc ¶
type InjectorFunc func(ctx *gin.Context, ls *LoginStatus) (err error)
type LoginStatus ¶
type LoginStatus struct { Token string Claim *UserClaims Err error Role Role State State // contains filtered or unexported fields }
LoginStatus 登录状态
type LoginWay ¶
type LoginWay uint8 // 登录方式
const ( LoginWayUnknown LoginWay = 0 // LoginWayEmail 邮箱+密码 LoginWayEmail LoginWay = 1 // LoginWayPhone 手机号+验证码 LoginWayPhone LoginWay = 2 // LoginWayWxWeb 微信网页端 LoginWayWxWeb LoginWay = 3 // LoginWayWxMp 微信公众号 LoginWayWxMp LoginWay = 4 // LoginWayWxMini 微信小程序 LoginWayWxMini LoginWay = 5 // LoginWayGithub github LoginWayGithub LoginWay = 6 // LoginWayWorkWechat 企业微信 LoginWayWorkWechat LoginWay = 7 )
type UserClaims ¶ added in v0.4.1
type UserClaims struct { // Uin 账号ID,主体+用户对应的唯一ID Uin uint `json:"c,omitempty"` // IssuedAt 创建时间 IssuedAt int64 `json:"t,omitempty"` // ExpiresAt 过期时间 ExpiresAt int64 `json:"e,omitempty"` // Issuer 签发者 区分不同签发者 Issuer string `json:"i,omitempty"` // Audience 接收者 Audience string `json:"a,omitempty"` // LoginWay 登录方式 LoginWay LoginWay `json:"l,omitempty"` }
UserClaims 用户信息
func (UserClaims) Valid ¶ added in v0.4.1
func (c UserClaims) Valid() error
Valid time based claims "exp, iat, nbf". There is no accounting for clock skew. As well, if any of the above claims are not in the token, it will still be considered a valid claim.
Click to show internal directories.
Click to hide internal directories.