Documentation ¶
Index ¶
- Constants
- type Authorization
- type Header
- type Payload
- type Subject
- func (self *Subject) Generate(secret string, refresh ...bool) (*Authorization, error)
- func (self *Subject) Refresh(accessToken, refreshToken, secret string, accessTime int64, interval ...int64) (*Authorization, error)
- func (self *Subject) Valid(accessToken, secret string, refresh bool, aud ...string) error
Constants ¶
View Source
const ( JWT = "JWT" SHA256 = "SHA256" QUARTER_HOUR = int64(900000) HALF_HOUR = int64(3600000) TWO_WEEK = int64(1209600000) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
type Payload ¶
type Payload struct { Sub string `json:"sub"` // 用户主体 Aud string `json:"aud"` // 接收token主体 Iss string `json:"iss"` // 签发token主体 Iat int64 `json:"iat"` // 授权token时间 Exp int64 `json:"exp"` // 授权token过期时间 Rxp int64 `json:"rxp"` // 续期token过期时间 Nbf int64 `json:"nbf"` // 定义在什么时间之前,该token都是不可用的 Jti string `json:"jti"` // 唯一身份标识,主要用来作为一次性token,从而回避重放攻击 Ext map[string]string `json:"ext"` // 扩展信息 }
type Subject ¶
func (*Subject) Generate ¶
func (self *Subject) Generate(secret string, refresh ...bool) (*Authorization, error)
生成Token
Click to show internal directories.
Click to hide internal directories.