Documentation ¶
Index ¶
Constants ¶
View Source
const AuthzAudience = "iam.authz.marmotedu.com"
View Source
const (
UsernameKey = "username"
)
Variables ¶
View Source
var ( ErrMissingKID = errors.New("") ErrMissingSecret = errors.New("") )
Functions ¶
This section is empty.
Types ¶
type AutoStrategy ¶
type AutoStrategy struct {
// contains filtered or unexported fields
}
根据 head 来使用相应的验证方式
func NewAutoStrategy ¶
func NewAutoStrategy(basic BasicStrategy, jwt JwtStrategy) AutoStrategy
总验证结构
func (AutoStrategy) AuthFunc ¶
func (as AutoStrategy) AuthFunc() gin.HandlerFunc
auto策略会根据 HTTP 头 Authorization: Basic XX.YY.ZZ和 Authorization : Bearer XX.YY.ZZ自动选择使用 Basic 认证还是 Bearer 认证。 使用策略模式
type BasicStrategy ¶
type BasicStrategy struct {
// contains filtered or unexported fields
}
Auth验证
func NewBasicStrategy ¶
func NewBasicStrategy(verification func(username string, password string) bool) BasicStrategy
func (BasicStrategy) AuthFunc ¶
func (a BasicStrategy) AuthFunc() gin.HandlerFunc
格式: $ curl -XPOST -H"Authorization: Basic YWRtaW46QWRtaW5AMjAyMQ== " http://127.0.0.1:8080/login # 用户名:密码通过base64加码后,通过HTTP Authorization Header进行传递,因为密码非明文,建议使用这种方式。
type CacheStrategy ¶
type CacheStrategy struct {
// contains filtered or unexported fields
}
实际这个是 bearer 认证的实现
func NewCacheStrategy ¶
func NewCacheStrategy(getSecret func(kid string) (Secret, error)) CacheStrategy
func (CacheStrategy) AuthFunc ¶
func (cache CacheStrategy) AuthFunc() gin.HandlerFunc
Authorization: Bearer XX.YY.ZZ 请求头中获取 XX.YY.ZZ,XX.YY.ZZ 即为 JWT Token cache 认证策略 这里是访问 api-auth-server 时使用的验证方式
type JwtStrategy ¶
type JwtStrategy struct {
ginjwt.GinJWTMiddleware
}
Click to show internal directories.
Click to hide internal directories.