Documentation ¶
Index ¶
Constants ¶
const AuthzAudience = "mxshop.czc.com"
AuthzAudience defines the value of jwt audience field.
Variables ¶
var ( ErrMissingKID = errors.New("Invalid token format: missing kid field in claims") ErrMissingSecret = errors.New("Can not obtain secret information from cache") )
Defined errors.
Functions ¶
func KeyExpired ¶
KeyExpired checks if a key has expired, if the value of user.SessionState.Expires is 0, it will be ignored.
Types ¶
type AutoStrategy ¶
type AutoStrategy struct {
// contains filtered or unexported fields
}
AutoStrategy defines authentication strategy which can automatically choose between Basic and Bearer according `Authorization` header.
func NewAutoStrategy ¶
func NewAutoStrategy(basic *BasicStrategy, jwt *JWTStrategy) AutoStrategy
NewAutoStrategy create auto strategy with basic strategy and jwt strategy. NewAutoStrategy 使用 basic策略 和 jwt策略 创建自动策略
func (AutoStrategy) AuthFunc ¶
func (a AutoStrategy) AuthFunc() gin.HandlerFunc
AuthFunc defines auto strategy as the gin authentication middleware.
type BasicStrategy ¶
type BasicStrategy struct {
// contains filtered or unexported fields
}
BasicStrategy defines Basic authentication strategy.
func NewBasicStrategy ¶
func NewBasicStrategy(compare func(c *gin.Context, username string, password string) bool) *BasicStrategy
NewBasicStrategy create basic strategy with compare function.
func (BasicStrategy) AuthFunc ¶
func (b BasicStrategy) AuthFunc() gin.HandlerFunc
AuthFunc defines basic strategy as the gin authentication middleware.
type CacheStrategy ¶
type CacheStrategy struct {
// contains filtered or unexported fields
}
CacheStrategy defines jwt bearer authentication strategy which called `cache strategy`. Secrets are obtained through grpc api interface and cached in memory. CacheStrategy 定义了被称为 cache strategy 的 JWT bearer 认证策略。 密钥通过 gRPC API 接口获取并缓存在内存中。
func NewCacheStrategy ¶
func NewCacheStrategy(get func(kid string) (Secret, error)) *CacheStrategy
NewCacheStrategy create cache strategy with function which can list and cache secrets. NewCacheStrategy 使用函数创建缓存策略,该函数可以列出并缓存机密信息。
func (CacheStrategy) AuthFunc ¶
func (cache CacheStrategy) AuthFunc() gin.HandlerFunc
AuthFunc defines cache strategy as the gin authentication middleware.
type JWTStrategy ¶
type JWTStrategy struct {
ginjwt.GinJWTMiddleware
}
JWTStrategy 定义了jwt承载身份验证策略.
func NewJWTStrategy ¶
func NewJWTStrategy(gjwt ginjwt.GinJWTMiddleware) *JWTStrategy
NewJWTStrategy create jwt bearer strategy with GinJWTMiddleware.
func (*JWTStrategy) AuthFunc ¶
func (j *JWTStrategy) AuthFunc() gin.HandlerFunc
AuthFunc 定义JWT承载策略作为gin身份验证中间件