Documentation ¶
Index ¶
- func DecodeToken(t string) (*apipb.CurrentUser, error)
- func EncodeToken(user *apipb.CurrentUser) (string, error)
- func ExtractorCurrentUser(t *jwt.Token) *apipb.CurrentUser
- func GetSessionID(t string) (string, error)
- func GetUserID(t string) (string, error)
- func InitTokenCache(key, redisAddr, redisUserName, redisPWD string, expired int)
- func SetSecretKey(key string)
- type Memory
- func (m *Memory) Del(userID, token string) error
- func (m *Memory) DelByUserID(userID string) error
- func (r *Memory) DelPrivateKey(sessionID string) error
- func (r *Memory) DelPublicKey(sessionID string) error
- func (m *Memory) Exists(userID, token string) (bool, error)
- func (r *Memory) GetPrivateKey(sessionID string) (string, bool)
- func (r *Memory) GetPublicKey(sessionID string) (string, bool)
- func (r *Memory) StorePrivateKey(sessionID string, privateKey string) error
- func (r *Memory) StorePublicKey(sessionID string, publicKey string) error
- func (m *Memory) StoreToken(userID, token string) error
- func (m *Memory) TokenExpired() int
- type Redis
- func (r *Redis) Del(userID, token string) error
- func (r *Redis) DelByUserID(userID string) error
- func (r *Redis) DelPrivateKey(sessionID string) error
- func (r *Redis) DelPublicKey(sessionID string) error
- func (r *Redis) Exists(userID, token string) (bool, error)
- func (r *Redis) GetPrivateKey(sessionID string) (string, bool)
- func (r *Redis) GetPublicKey(sessionID string) (string, bool)
- func (r *Redis) StorePrivateKey(sessionID string, privateKey string) error
- func (r *Redis) StorePublicKey(sessionID string, publicKey string) error
- func (r *Redis) StoreToken(userID, token string) error
- func (r *Redis) TokenExpired() int
- type TokenCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractorCurrentUser ¶
func ExtractorCurrentUser(t *jwt.Token) *apipb.CurrentUser
func GetSessionID ¶
func InitTokenCache ¶
Types ¶
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) DelByUserID ¶
func (*Memory) DelPrivateKey ¶
func (*Memory) DelPublicKey ¶
func (*Memory) StorePrivateKey ¶
func (*Memory) StorePublicKey ¶
func (*Memory) StoreToken ¶
func (*Memory) TokenExpired ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func (*Redis) DelByUserID ¶
func (*Redis) DelPrivateKey ¶
func (*Redis) DelPublicKey ¶
func (*Redis) StorePrivateKey ¶
func (*Redis) StorePublicKey ¶
func (*Redis) StoreToken ¶
func (*Redis) TokenExpired ¶
type TokenCache ¶
type TokenCache interface { //DelByUserID 删除该用户所有token DelByUserID(userID string) error //Del 删除该用户指定Token Del(userID, token string) error //Exists 判断Token是否存在 Exists(userID, token string) (bool, error) //StoreToken 存储Token StoreToken(userID, token string) error //TokenExpired Token过期时间,单位分钟 TokenExpired() int StorePrivateKey(sessionID string, privateKey string) error GetPrivateKey(sessionID string) (string, bool) DelPrivateKey(sessionID string) error StorePublicKey(sessionID string, publicKey string) error GetPublicKey(sessionID string) (string, bool) DelPublicKey(sessionID string) error }
var DefaultTokenCache TokenCache
func NewMemory ¶
func NewMemory(expired int) TokenCache
func NewRedis ¶
func NewRedis(addr, userName, pwd string, expired int) TokenCache
Click to show internal directories.
Click to hide internal directories.