Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DefaultToken ¶
type DefaultToken struct { LastLoginIP string `json:"last_login_ip"` UserID int64 `json:"user_id"` Telephone string `json:"telepone"` Nickname string `json:"nickname"` RedisTokenKey string `json:"token_key"` ExpiredAt int64 `json:"expired_at"` // 时间戳 ms }
DefaultToken . claims for jwt
func (*DefaultToken) MarshalBinary ¶
func (s *DefaultToken) MarshalBinary() ([]byte, error)
MarshalBinary .
func (*DefaultToken) SetExpiration ¶
func (s *DefaultToken) SetExpiration(d time.Duration)
SetExpiration to update DefaultToken.ExpiredAt timestamp
func (*DefaultToken) UnmarshalBinary ¶
func (s *DefaultToken) UnmarshalBinary(data []byte) error
UnmarshalBinary .
type IToken ¶
type IToken interface { // functions for redis encoding and decoding encoding.BinaryMarshaler encoding.BinaryUnmarshaler // following methods is provided to ITokenManager to op with token // TokenKey got key in redis or somewhere to find the token TokenKey() string // Expiration got time.Duration(int64) of token will expire at Expiration() time.Duration // Valid will raise error related to the method how to validate the information contained by token Valid() error // SetExpiration to update token expired time SetExpiration(d time.Duration) }
IToken . an interface which contains necessary information of user who has logined to web application 支持多平台
type ITokenManager ¶
type ITokenManager interface { Set(tok IToken) error Exists(tok IToken) bool Expire(tok IToken) error Refresh(tok IToken, d time.Duration) error Get(key string, tok IToken) error PraseToken(token string, tok IToken) error Token(tok IToken) (string, error) }
ITokenManager . 1. 能生成sessionkey 和 session 内容 2. 并发安全 3. 支持多平台token不冲突
func NewJwtTokenManager ¶
func NewJwtTokenManager(rc *redis.Client, signedKey string) ITokenManager
NewJwtTokenManager .
Click to show internal directories.
Click to hide internal directories.