Versions in this module Expand all Collapse all v1 v1.1.4 Feb 18, 2022 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("GfJWTMiddleware.Authenticator func is undefined") + 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" + func GetToken(r *ghttp.Request) string + type GfJWTMiddleware struct + Authenticator func(r *ghttp.Request) (interface{}, error) + Authorizator func(data interface{}, r *ghttp.Request) bool + CacheAdapter gcache.Adapter + CookieDomain string + CookieHTTPOnly bool + CookieName string + DisabledAbort bool + HTTPStatusMessageFunc func(e error, r *ghttp.Request) string + IdentityHandler func(*ghttp.Request) interface{} + IdentityKey string + Key []byte + LoginResponse func(*ghttp.Request, int, string, time.Time) + LogoutResponse func(*ghttp.Request, int) + MaxRefresh time.Duration + PayloadFunc func(data interface{}) MapClaims + PrivKeyFile string + PubKeyFile string + Realm string + RefreshResponse func(*ghttp.Request, int, string, time.Time) + SecureCookie bool + SendAuthorization bool + SendCookie bool + SigningAlgorithm string + TimeFunc func() time.Time + Timeout time.Duration + TokenHeadName string + TokenLookup string + Unauthorized func(*ghttp.Request, int, string) + func New(m *GfJWTMiddleware) (*GfJWTMiddleware, error) + func (mw *GfJWTMiddleware) CheckIfTokenExpire(r *ghttp.Request) (jwt.MapClaims, string, error) + func (mw *GfJWTMiddleware) GetClaimsFromJWT(r *ghttp.Request) (MapClaims, string, error) + func (mw *GfJWTMiddleware) LoginHandler(r *ghttp.Request) + func (mw *GfJWTMiddleware) LogoutHandler(r *ghttp.Request) + func (mw *GfJWTMiddleware) MiddlewareFunc() ghttp.HandlerFunc + func (mw *GfJWTMiddleware) MiddlewareInit() error + func (mw *GfJWTMiddleware) ParseToken(r *ghttp.Request) (*jwt.Token, error) + func (mw *GfJWTMiddleware) RefreshHandler(r *ghttp.Request) + func (mw *GfJWTMiddleware) RefreshToken(r *ghttp.Request) (string, time.Time, error) + func (mw *GfJWTMiddleware) TokenGenerator(data interface{}) (string, time.Time, error) + type MapClaims map[string]interface + func ExtractClaims(r *ghttp.Request) MapClaims