Versions in this module Expand all Collapse all v0 v0.0.2 Jul 6, 2026 Changes in this version + const MsgErrInstanceNotInit + func AddExcludePaths(urls ...string) + func ClearPaths() + func GenerateToken(userID string) (string, error) + func GetTokenByUserKey(ctx context.Context, userID string) (string, error) + func GetUserIDByToken(ctx context.Context, token string) (*gvar.Var, error) + func IsLogin(ctx context.Context, token string) (userID *gvar.Var, isLoggedIn bool, err error) + func Login(ctx context.Context, userID string) (string, error) + func Logout(ctx context.Context, userID string) error + func LogoutByToken(ctx context.Context, token string) error + func RemovePaths(urls ...string) + func SearchPath(url string) bool v0.0.1 Jul 6, 2026 Changes in this version + const CacheModeCache + const CacheModeRedis + const MsgErrDataEmpty + const MsgErrExpiredOrNotExist + const MsgErrTokenEmpty + const MsgErrUserIDEmpty + const TokenKeyPrefix + const UserKeyPrefix + func GetRequestToken(r *ghttp.Request) (string, error) + type Config struct + AuthExcludePaths []string + AuthHeaderName string + CacheMode int8 + CachePreKey string + EnableRenew bool + MultiLogin bool + RenewThreshold time.Duration + RenewTimeout time.Duration + TokenExpire time.Duration + TokenPrefix string + TokenStyle TokenStyle + func NewConfigFromCtx(ctx context.Context) *Config + type Manager struct + var Instance *Manager + func Init(config *Config) *Manager + func (m *Manager) AddExcludePaths(urls ...string) + func (m *Manager) ClearPaths() + func (m *Manager) GenerateToken(userID string) (string, error) + func (m *Manager) GetTokenByUserKey(ctx context.Context, userID string) (string, error) + func (m *Manager) GetUserIDByToken(ctx context.Context, token string) (*gvar.Var, error) + func (m *Manager) IsLogin(ctx context.Context, token string) (userID *gvar.Var, isLoggedIn bool, err error) + func (m *Manager) Login(ctx context.Context, userID string) (string, error) + func (m *Manager) Logout(ctx context.Context, userID string) error + func (m *Manager) LogoutByToken(ctx context.Context, token string) error + func (m *Manager) RemovePaths(url ...string) + func (m *Manager) SearchPath(url string) bool + type Middleware struct + ResFunc func(r *ghttp.Request, err error) + func NewMiddleware(resFunc ...func(r *ghttp.Request, err error)) *Middleware + func (m *Middleware) Auth(r *ghttp.Request) + type TokenStyle string + const TokenStyleRand128 + const TokenStyleRand64 + const TokenStyleUUID