Versions in this module Expand all Collapse all v3 v3.0.0 Nov 27, 2024 Changes in this version + var ErrEmptyAuthHeader = errors.New("auth header is empty") + var ErrEmptyCookieToken = errors.New("cookie token is empty") + var ErrEmptyParamToken = errors.New("parameter token is empty") + var ErrEmptyQueryToken = errors.New("query token is empty") + var ErrExpiredToken = errors.New("token is expired") + var ErrFailedAuthentication = errors.New("incorrect Username or Password") + var ErrFailedTokenCreation = errors.New("failed to create JWT Token") + var ErrForbidden = errors.New("you don't have permission to access this resource") + var ErrInvalidAuthHeader = errors.New("auth header is invalid") + var ErrInvalidPrivKey = errors.New("private key invalid") + var ErrInvalidPubKey = errors.New("public key invalid") + var ErrInvalidSigningAlgorithm = errors.New("invalid signing algorithm") + var ErrInvalidToken = errors.New("token is invalid") + var ErrMissingAuthenticatorFunc = errors.New("ginJWTMiddleware.Authenticator func is undefined") + var ErrMissingContext = errors.New("context is required") + var ErrMissingExpField = errors.New("missing exp field") + var ErrMissingIdentity = errors.New("payload don't have identity key and identity value") + var ErrMissingLoginValues = errors.New("missing Username or Password") + var ErrMissingSecretKey = errors.New("secret key is required") + var ErrNoPrivKeyFile = errors.New("private key file unreadable") + var ErrNoPubKeyFile = errors.New("public key file unreadable") + var ErrWrongFormatOfExp = errors.New("exp must be float64 format") + var IdentityKey = "identity" + var PayloadKey = "JWT_PAYLOAD" + var TokenKey = "JWT_TOKEN" + type GfJWTMiddleware struct + Authenticator func(ctx context.Context) (interface{}, error) + Authorizator func(data interface{}, ctx context.Context) bool + BlacklistPrefix string + CacheAdapter gcache.Adapter + CookieDomain string + CookieHTTPOnly bool + CookieMaxAge time.Duration + CookieName string + DisabledAbort bool + HTTPStatusMessageFunc func(e error, ctx context.Context) string + IdentityHandler func(ctx context.Context) interface{} + IdentityKey string + Key []byte + KeyFunc func(token *jwt.Token) (interface{}, error) + MaxRefresh time.Duration + PayloadFunc func(data interface{}) MapClaims + PrivKeyBytes []byte + PrivKeyFile string + PrivateKeyPassphrase string + PubKeyBytes []byte + PubKeyFile string + Realm string + SecureCookie bool + SendAuthorization bool + SendCookie bool + SigningAlgorithm string + TimeFunc func() time.Time + Timeout time.Duration + TokenHeadName string + TokenLookup string + Unauthorized func(ctx context.Context, code int, message string) + func New(mw *GfJWTMiddleware) *GfJWTMiddleware + func (mw *GfJWTMiddleware) CheckIfTokenExpire(ctx context.Context) (jwt.MapClaims, string, error) + func (mw *GfJWTMiddleware) GetClaimsFromJWT(ctx context.Context) (MapClaims, string, error) + func (mw *GfJWTMiddleware) GetIdentity(ctx context.Context) interface{} + func (mw *GfJWTMiddleware) GetPayload(ctx context.Context) string + func (mw *GfJWTMiddleware) GetToken(ctx context.Context) string + func (mw *GfJWTMiddleware) LoginHandler(ctx context.Context) (tokenString string, expire time.Time) + func (mw *GfJWTMiddleware) LogoutHandler(ctx context.Context) + func (mw *GfJWTMiddleware) MiddlewareFunc() ghttp.HandlerFunc + func (mw *GfJWTMiddleware) RefreshHandler(ctx context.Context) (tokenString string, expire time.Time) + func (mw *GfJWTMiddleware) RefreshToken(ctx context.Context) (string, time.Time, error) + func (mw *GfJWTMiddleware) TokenGenerator(data interface{}) (string, time.Time, error) + type MapClaims map[string]interface + func ExtractClaims(ctx context.Context) MapClaims + func ExtractClaimsFromToken(token *jwt.Token) MapClaims