Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrorTokenMissing = "禁止访问" ErrorTokenMalformed = "令牌错误" ErrorTokenNotValidYet = "令牌不存在" ErrorTokenExpired = "令牌过期" ErrorTokenInvalid = "令牌无效" )
View Source
const ( TokenKey = "__JWT_TOKEN" ContextUserKey = "__CONTEXT_USER" )
Variables ¶
Functions ¶
func SetGlobalCryptoKey ¶
func SetGlobalCryptoKey(key string)
Types ¶
type ItfTokenStore ¶
type JWT ¶
type JWT struct { Expire int64 Store ItfTokenStore // contains filtered or unexported fields }
JWT is middleware for the RPC web framework that provides JWT authentication.
func DefaultJWT ¶
func DefaultJWT() *JWT
func NewJWTWithStore ¶
func NewJWTWithStore(store ItfTokenStore) *JWT
type RedisTokenStore ¶
type RedisTokenStore struct {
// contains filtered or unexported fields
}
func NewRedisTokenStore ¶
func NewRedisTokenStore(c *redis.Client) *RedisTokenStore
func (*RedisTokenStore) ClearExpiredToken ¶
func (r *RedisTokenStore) ClearExpiredToken()
func (*RedisTokenStore) DelToken ¶
func (r *RedisTokenStore) DelToken(key string)
func (*RedisTokenStore) GetToken ¶
func (r *RedisTokenStore) GetToken(key string) (t *Token, has bool)
func (*RedisTokenStore) SetToken ¶
func (r *RedisTokenStore) SetToken(key string, t *Token)
Click to show internal directories.
Click to hide internal directories.