Versions in this module Expand all Collapse all v0 v0.1.0 May 2, 2021 Changes in this version + var ErrEmptyAuthHeader = errors.New("auth标头为空") + var ErrEmptyCookieToken = errors.New(" Cookie token为空") + var ErrEmptyParamToken = errors.New("参数token为空") + var ErrEmptyQueryToken = errors.New("查询token为空") + var ErrExpiredToken = errors.New("token已过期") + var ErrFailedAuthentication = errors.New("用户名或密码错误") + var ErrFailedTokenCreation = errors.New("无法创建JWT Token") + var ErrForbidden = errors.New("您无权访问此资源") + var ErrInvalidAuthHeader = errors.New("auth标头无效") + var ErrInvalidPrivateKey = errors.New("私钥无效") + var ErrInvalidPubKey = errors.New("公钥无效") + var ErrInvalidSigningAlgorithm = errors.New("无效签名算法") + var ErrMissingAuthFunc = errors.New(" JWTMiddleware.AuthFunc函数未定义!") + var ErrMissingExpField = errors.New("缺少exp字段") + var ErrMissingLoginValues = errors.New("缺少用户名或密码") + var ErrMissingSecretKey = errors.New("需要密钥") + var ErrNoPrivateKeyFile = errors.New("私钥文件不可读") + var ErrNoPubKeyFile = errors.New("公钥文件不可读") + var ErrWrongFormatOfExp = errors.New("exp必须为float64格式") + var IdentityKey = "identity" + func GetToken(c *gin.Context) string + type JWTMiddleware struct + AuthAfter func(data interface{}, c *gin.Context) bool + AuthFunc func(c *gin.Context) (interface{}, error) + CookieDomain string + CookieHTTPOnly bool + CookieMaxAge time.Duration + CookieName string + CookieSameSite http.SameSite + DisabledAbort bool + HTTPStatusMsgFunc func(e error, c *gin.Context) string + IdentityHandler func(*gin.Context) interface{} + IdentityKey string + Key []byte + LoginResponse func(*gin.Context, int, string, time.Time) + LogoutResponse func(*gin.Context, int) + MaxRefresh time.Duration + PayloadFunc func(data interface{}) MapClaims + PrivateKeyByte []byte + PrivateKeyFile string + PubKeyByte []byte + PubKeyFile string + Realm string + RefreshResponse func(*gin.Context, int, string, time.Time) + SecureCookie bool + SendAuthorization bool + SendCookie bool + SigningAlgorithm string + TimeFunc func() time.Time + Timeout time.Duration + TokenHeadName string + TokenLookup string + UnAuthFunc func(*gin.Context, int, string) + func New(m *JWTMiddleware) (*JWTMiddleware, error) + func (mw *JWTMiddleware) CheckIfTokenExpire(c *gin.Context) (jwt.MapClaims, error) + func (mw *JWTMiddleware) GetClaimsFromJWT(c *gin.Context) (MapClaims, error) + func (mw *JWTMiddleware) Init() error + func (mw *JWTMiddleware) LoginHandler(c *gin.Context) + func (mw *JWTMiddleware) LogoutHandler(c *gin.Context) + func (mw *JWTMiddleware) MiddlewareFunc() gin.HandlerFunc + func (mw *JWTMiddleware) ParseToken(c *gin.Context) (*jwt.Token, error) + func (mw *JWTMiddleware) ParseTokenStr(token string) (*jwt.Token, error) + func (mw *JWTMiddleware) RefreshHandler(c *gin.Context) + func (mw *JWTMiddleware) RefreshToken(c *gin.Context) (string, time.Time, error) + func (mw *JWTMiddleware) TokenGenerate(data interface{}) (string, time.Time, error) + type MapClaims map[string]interface + func ExtractClaims(c *gin.Context) MapClaims + func ExtractClaimsFromToken(token *jwt.Token) MapClaims