Documentation ¶
Overview ¶
Package auth defines authentication strategy like Basic, Bearer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingKID = errors.New("missing kid in token header") ErrMissingSecret = errors.New("missing secret in cache") )
Defined errors.
Functions ¶
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, jwt middleware.AuthStrategy) AutoStrategy
NewAutoStrategy create auto strategy with basic strategy and jwt strategy.
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(username string, password string) bool) BasicStrategy
NewBasicStrategy creates basic strategy with compare function.
func (BasicStrategy) AuthFunc ¶
func (b BasicStrategy) AuthFunc() gin.HandlerFunc
AuthFunc implements the AuthStrategy interface.
type JWTExStrategy ¶
type JWTExStrategy struct {
// contains filtered or unexported fields
}
JWTExStrategy defines jwt bearer authentication strategy with user-specific secret.
func NewJWTExStrategy ¶
func NewJWTExStrategy(get func(kid string) (Secret, error)) JWTExStrategy
NewJWTExStrategy creates a jwt strategy.
func (JWTExStrategy) AuthFunc ¶
func (j JWTExStrategy) AuthFunc() gin.HandlerFunc
AuthFunc defines jwt strategy as the gin authentication middleware.
type JWTStrategy ¶
type JWTStrategy struct {
ginjwt.GinJWTMiddleware
}
JWTStrategy defines jwt bearer authentication strategy.
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 defines jwt bearer strategy as the gin authentication middleware.