Versions in this module Expand all Collapse all v1 v1.0.0 Aug 12, 2023 Changes in this version + const ErrorsParseTokenFail + const ErrorsTokenInvalid + const ErrorsTokenMalFormed + const ErrorsTokenNotActiveYet + const FailedAuthCode + const JwtTokenExpired + const JwtTokenFormatErrCode + const JwtTokenInvalid + const JwtTokenOK + type AuthFailed struct + Code int + Message string + type CustomClaims struct + Data interface{} + type GfToken struct + CacheKey string + EncryptKey []byte + ExcludePaths g.SliceStr + MaxRefresh int64 + MultiLogin bool + ServerName string + Timeout int64 + func NewGfToken(opts ...OptionFunc) *GfToken + func (m *GfToken) AuthPath(urlPath string) bool + func (m *GfToken) DecryptToken(ctx context.Context, token string) (DecryptStr, uuid string, err error) + func (m *GfToken) EncryptToken(ctx context.Context, key string, randStr ...string) (encryptStr, uuid string, err error) + func (m *GfToken) GenerateToken(ctx context.Context, key string, data interface{}) (keys string, err error) + func (m *GfToken) GetRequestToken(r *ghttp.Request) (token string) + func (m *GfToken) GetToken(r *ghttp.Request) (tData *TokenData, err error) + func (m *GfToken) GetTokenData(ctx context.Context, token string) (tData *TokenData, key string, err error) + func (m *GfToken) IsEffective(ctx context.Context, token string) bool + func (m *GfToken) IsLogin(r *ghttp.Request) (b bool, failed *AuthFailed) + func (m *GfToken) IsNotExpired(token string) (*CustomClaims, int) + func (m *GfToken) IsRefresh(token string) bool + func (m *GfToken) Middleware(group *ghttp.RouterGroup) error + func (m *GfToken) ParseToken(r *ghttp.Request) (*CustomClaims, error) + func (m *GfToken) RefreshToken(oldToken string) (newToken string, err error) + func (m *GfToken) RemoveToken(ctx context.Context, token string) (err error) + type JwtSign struct + SigningKey []byte + func CreateMyJWT(JwtTokenSignKey string) *JwtSign + func (j *JwtSign) CreateToken(claims CustomClaims) (string, error) + func (j *JwtSign) ParseToken(tokenString string) (*CustomClaims, error) + func (j *JwtSign) RefreshToken(tokenString string, extraAddSeconds int64) (string, error) + type OptionFunc func(*GfToken) + func WithCacheKey(value string) OptionFunc + func WithEncryptKey(value []byte) OptionFunc + func WithExcludePaths(value g.SliceStr) OptionFunc + func WithGCache() OptionFunc + func WithGRedis(redis ...*gredis.Redis) OptionFunc + func WithGRedisConfig(redisConfig ...*gredis.Config) OptionFunc + func WithMaxRefresh(value int64) OptionFunc + func WithMultiLogin(b bool) OptionFunc + func WithServerName(value string) OptionFunc + func WithTimeout(value int64) OptionFunc + func WithTimeoutAndMaxRefresh(timeout, maxRefresh int64) OptionFunc + func WithUserJwt(key string) OptionFunc + type TokenData struct + JwtToken string + UuId string