Documentation ¶
Index ¶
Constants ¶
View Source
const AuthzAudience = "skt.authz.changaolee.com"
AuthzAudience 定义 jwt 中 audience 字段的值.
Variables ¶
View Source
var ( ErrMissingKID = errors.New("Invalid token format: missing kid field in claims") ErrMissingSecret = errors.New("Can not obtain secret information from cache") )
Functions ¶
Types ¶
type AutoStrategy ¶
type AutoStrategy struct {
// contains filtered or unexported fields
}
AutoStrategy 定义了可自动选择的身份认证策略. 支持在 Basic 和 JWT Bearer 认证间切换.
func NewAutoStrategy ¶
func NewAutoStrategy(basic, jwt middleware.AuthStrategy) AutoStrategy
NewAutoStrategy 基于给定的 Basic 和 JWT Bearer 认证策略创建一个 AutoStrategy.
func (AutoStrategy) AuthFunc ¶
func (a AutoStrategy) AuthFunc() gin.HandlerFunc
type BasicStrategy ¶
type BasicStrategy struct {
// contains filtered or unexported fields
}
BasicStrategy 定义 Basic 认证策略.
func NewBasicStrategy ¶
func NewBasicStrategy(compare CompareFunc) BasicStrategy
NewBasicStrategy 基于给定的 compare 方法创建一个 Basic 认证策略.
func (BasicStrategy) AuthFunc ¶
func (b BasicStrategy) AuthFunc() gin.HandlerFunc
AuthFunc 定义 Basic 认证策略作为 Gin 中间件.
type CacheStrategy ¶
type CacheStrategy struct {
// contains filtered or unexported fields
}
CacheStrategy 定义 Cache 认证策略(基于缓存实现的 JWT Bearer 认证).
func NewCacheStrategy ¶
func NewCacheStrategy(get getSecretFunc) CacheStrategy
NewCacheStrategy 基于给定的 get 方法创建一个 Cache 认证策略.
func (CacheStrategy) AuthFunc ¶
func (cache CacheStrategy) AuthFunc() gin.HandlerFunc
type CompareFunc ¶
type JWTStrategy ¶
type JWTStrategy struct {
ginjwt.GinJWTMiddleware
}
func NewJWTStrategy ¶
func NewJWTStrategy(gjwt ginjwt.GinJWTMiddleware) JWTStrategy
NewJWTStrategy 创建一个 JWT Bearer 认证策略.
func (JWTStrategy) AuthFunc ¶
func (j JWTStrategy) AuthFunc() gin.HandlerFunc
AuthFunc 定义 JWT Bearer 认证策略作为 Gin 中间件.
Click to show internal directories.
Click to hide internal directories.