Documentation ¶
Index ¶
Constants ¶
View Source
const ( UsernameKey = "username" KeyUserID = "userID" UserIP = "ip" )
Variables ¶
View Source
var ( TokenExpired = errors.New("token is expired") TokenNotValidYet = errors.New("token not active yet") TokenMalformed = errors.New("that's not even a token") TokenInvalid = errors.New("couldn't handle this token") )
View Source
var Middlewares = defaultMiddlewares()
Functions ¶
func Cors ¶
func Cors() gin.HandlerFunc
func TracingHandler ¶
func TracingHandler(service string) gin.HandlerFunc
Types ¶
type AuthOperator ¶
type AuthOperator struct {
// contains filtered or unexported fields
}
AuthOperator 认证实体工厂类
func (*AuthOperator) AuthFunc ¶
func (ao *AuthOperator) AuthFunc() gin.HandlerFunc
AuthFunc 返回一个 gin.HandlerFunc 中间件接口函数
func (*AuthOperator) SetStrategy ¶
func (ao *AuthOperator) SetStrategy(s AuthStrategy)
type AuthStrategy ¶
type AuthStrategy interface { // AuthFunc 相当于是实现了一个名为 AuthFunc 的中间件 AuthFunc() gin.HandlerFunc }
AuthStrategy 认证策略
type CustomClaims ¶ added in v0.0.4
type JWT ¶ added in v0.0.4
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateToken ¶ added in v0.0.4
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
创建一个token
func (*JWT) ParseToken ¶ added in v0.0.4
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
解析 token
Click to show internal directories.
Click to hide internal directories.