Documentation
¶
Index ¶
- Constants
- Variables
- func BuildRequestID() string
- func BuildSignParams(appID string, body interface{}) (map[string]string, error)
- func DefaultErrorHandler(c *gin.Context, code int, message string, detail string)
- func GenerateAppSecret(length int) (string, error)
- func GenerateNonce(length int) string
- func GenerateSecureNonce(length int) (string, error)
- func GenerateSign(params map[string]string, appSecret string) string
- func GetAppIDFromContext(c *gin.Context) (string, bool)
- func GetUserID(c *gin.Context) (uint64, bool)
- func GetUsername(c *gin.Context) (string, bool)
- func HashToken(token string) string
- func MaskSecret(secret string) string
- func QuickSign(appID, appSecret string, body interface{}) (params map[string]string, sign string, err error)
- func SanitizeIP(ip string) string
- func SignatureExample(appID, appSecret string, additionalParams map[string]string) map[string]string
- func ValidateAppID(appID string) error
- func ValidateTimestamp(timestamp string, tolerance int64) bool
- func VerifySign(params map[string]string, appSecret string, receivedSign string) bool
- func VerifySignWithDebug(params map[string]string, appSecret string, receivedSign string) (bool, string)
- type AppConfig
- type AuthError
- type AuthMiddleware
- func (m *AuthMiddleware) AdminAuth() gin.HandlerFunc
- func (m *AuthMiddleware) Authenticate(errorHandler ...ErrorHandler) gin.HandlerFunc
- func (m *AuthMiddleware) JWTAuth() gin.HandlerFunc
- func (m *AuthMiddleware) RefreshAppCache()
- func (m *AuthMiddleware) WithConfig(config *Config) *AuthMiddleware
- func (m *AuthMiddleware) WithJWT(jwtService *JWTService) *AuthMiddleware
- func (m *AuthMiddleware) WithLogger(logger Logger) *AuthMiddleware
- type Claims
- type Client
- func (c *Client) DebugSign(body interface{})
- func (c *Client) Delete(path string, headers ...map[string]string) (*http.Response, error)
- func (c *Client) DeleteJSON(path string, result interface{}) error
- func (c *Client) DoJSON(method, path string, body interface{}, result interface{}) error
- func (c *Client) Get(path string, headers ...map[string]string) (*http.Response, error)
- func (c *Client) GetJSON(path string, result interface{}) error
- func (c *Client) Post(path string, body interface{}, headers ...map[string]string) (*http.Response, error)
- func (c *Client) PostJSON(path string, body interface{}, result interface{}) error
- func (c *Client) Put(path string, body interface{}, headers ...map[string]string) (*http.Response, error)
- func (c *Client) PutJSON(path string, body interface{}, result interface{}) error
- func (c *Client) Request(method, path string, body interface{}, headers ...map[string]string) (*http.Response, error)
- type ClientOption
- type Config
- func (c *Config) AddApp(app *AppConfig)
- func (c *Config) GetApp(appID string) (*AppConfig, bool)
- func (c *Config) GetApps() map[string]*AppConfig
- func (c *Config) GetEnabledAppCount() int
- func (c *Config) LoadFromJSON(filePath string) error
- func (c *Config) LoadFromYAML(filePath string) error
- func (c *Config) RemoveApp(appID string)
- func (c *Config) SaveToJSON(filePath string) error
- func (c *Config) SaveToYAML(filePath string) error
- func (c *Config) Validate() error
- type ConfigBuilder
- func (b *ConfigBuilder) AddApp(app *AppConfig) *ConfigBuilder
- func (b *ConfigBuilder) AddSimpleApp(appID, appSecret, appName string) *ConfigBuilder
- func (b *ConfigBuilder) Build() (*Config, error)
- func (b *ConfigBuilder) MustBuild() *Config
- func (b *ConfigBuilder) SetDefaultRateLimit(limit int) *ConfigBuilder
- func (b *ConfigBuilder) SetEnableIPCheck(enabled bool) *ConfigBuilder
- func (b *ConfigBuilder) SetTimestampTolerance(seconds int64) *ConfigBuilder
- type ConfigOption
- type ErrorCode
- type ErrorHandler
- type ErrorResponse
- type InMemoryBlacklist
- func (b *InMemoryBlacklist) Add(tokenHash string, expiry time.Time) error
- func (b *InMemoryBlacklist) Cleanup() error
- func (b *InMemoryBlacklist) Clear()
- func (b *InMemoryBlacklist) Count() int
- func (b *InMemoryBlacklist) GetExpiry(tokenHash string) (time.Time, bool)
- func (b *InMemoryBlacklist) IsBlacklisted(tokenHash string) bool
- func (b *InMemoryBlacklist) StartAutoCleanup(interval time.Duration)
- func (b *InMemoryBlacklist) StopAutoCleanup()
- type JWTConfig
- type JWTService
- func (s *JWTService) GenerateAccessToken(userID uint64, username, role, appID string, custom map[string]interface{}) (string, error)
- func (s *JWTService) GenerateRefreshToken(userID uint64, username string) (string, error)
- func (s *JWTService) GenerateTokenPair(userID uint64, username, role, appID string, custom map[string]interface{}) (*TokenPair, error)
- func (s *JWTService) GetConfig() JWTConfig
- func (s *JWTService) ParseToken(tokenString string) (*Claims, error)
- func (s *JWTService) RefreshAccessToken(refreshToken string, role, appID string, custom map[string]interface{}) (string, error)
- func (s *JWTService) RevokeToken(tokenString string) error
- func (s *JWTService) ValidateAccessToken(tokenString string) (*Claims, error)
- func (s *JWTService) ValidateRefreshToken(tokenString string) (*Claims, error)
- func (s *JWTService) WithBlacklist(blacklist TokenBlacklist) *JWTService
- type Logger
- type Options
- type RateLimiter
- type RedisConfig
- type SuccessResponse
- type TokenBlacklist
- type TokenBlacklistConfig
- type TokenPair
- type TokenType
Constants ¶
const ( // JWT 相关常量 HeaderAuthorization = "Authorization" BearerPrefix = "Bearer " // Context Keys - JWT ContextKeyUserID = "goauth_user_id" ContextKeyUsername = "goauth_username" ContextKeyRole = "goauth_role" ContextKeyClaims = "goauth_claims" )
const ( // 认证头部字段 HeaderAppID = "X-App-Id" HeaderTimestamp = "X-Timestamp" HeaderNonce = "X-Nonce" HeaderSign = "X-Sign" // 上下文键 ContextKeyApp = "goauth_app" ContextKeyAppID = "goauth_app_id" )
Variables ¶
var ( ErrInvalidParams = NewAuthError( ErrCodeInvalidParams, "请求参数不完整或格式错误", "", http.StatusBadRequest, ) ErrAppNotFound = NewAuthError( ErrCodeAppNotFound, "应用不存在", "", http.StatusUnauthorized, ) ErrAppDisabled = NewAuthError( ErrCodeAppDisabled, "应用已被禁用", "", http.StatusUnauthorized, ) ErrInvalidTimestamp = NewAuthError( ErrCodeInvalidTimestamp, "时间戳无效", "时间戳格式错误或超出有效期", http.StatusBadRequest, ) ErrInvalidSign = NewAuthError( ErrCodeInvalidSign, "签名验证失败", "", http.StatusUnauthorized, ) ErrIPNotAllowed = NewAuthError( ErrCodeIPNotAllowed, "IP地址不在白名单中", "", http.StatusForbidden, ) ErrRateLimitExceeded = NewAuthError( ErrCodeRateLimitExceeded, "请求过于频繁", "", http.StatusTooManyRequests, ) )
预定义的错误
var ( // ErrTimestampExpired 时间戳过期错误 ErrTimestampExpired = errors.New("timestamp expired") // ErrNonceReused Nonce重复使用错误 ErrNonceReused = errors.New("nonce already used") // ErrSignatureMismatch 签名不匹配错误 ErrSignatureMismatch = errors.New("signature mismatch") // ErrRequestBodyInvalid 请求体无效错误 ErrRequestBodyInvalid = errors.New("request body invalid") // ErrConfigInvalid 配置无效错误 ErrConfigInvalid = errors.New("config invalid") )
标准错误变量(用于 errors.Is 判断)
Functions ¶
func BuildSignParams ¶
BuildSignParams 构建签名参数(便捷方法)
func DefaultErrorHandler ¶
DefaultErrorHandler 默认错误处理
func GenerateAppSecret ¶
GenerateAppSecret 生成应用密钥
func GenerateNonce ¶
GenerateNonce 生成随机字符串 使用 crypto/rand 生成密码学安全的随机数
func GenerateSecureNonce ¶
GenerateSecureNonce 生成加密安全的随机字符串
func GenerateSign ¶
GenerateSign 生成API签名 签名算法:HMAC-SHA256 签名步骤: 1. 将所有参数(除sign外)按参数名ASCII码从小到大排序 2. 使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串 3. 使用应用的AppSecret对上述字符串进行HMAC-SHA256签名
func GetAppIDFromContext ¶
GetAppIDFromContext 从上下文中获取应用ID
func GetUsername ¶ added in v0.0.7
GetUsername 从 Context 获取用户名
func QuickSign ¶
func QuickSign(appID, appSecret string, body interface{}) (params map[string]string, sign string, err error)
QuickSign 快速生成签名(便捷方法)
func SignatureExample ¶
func SignatureExample(appID, appSecret string, additionalParams map[string]string) map[string]string
SignatureExample 生成API签名示例
func ValidateTimestamp ¶
ValidateTimestamp 验证时间戳
func VerifySign ¶
VerifySign 验证API签名
Types ¶
type AppConfig ¶
type AppConfig struct {
AppID string `json:"app_id" yaml:"app_id"` // 应用ID
AppSecret string `json:"app_secret" yaml:"app_secret"` // 应用密钥
AppName string `json:"app_name" yaml:"app_name"` // 应用名称
RequireSign bool `json:"require_sign" yaml:"require_sign"` // 是否需要签名验证
IPWhitelist []string `json:"ip_whitelist" yaml:"ip_whitelist"` // IP白名单
AllowedRoutes []string `json:"allowed_routes" yaml:"allowed_routes"` // 允许访问的路由
RateLimit int `json:"rate_limit" yaml:"rate_limit"` // 速率限制(次/分钟)
Enabled bool `json:"enabled" yaml:"enabled"` // 是否启用
}
AppConfig 应用配置
type AuthError ¶
type AuthError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Detail string `json:"detail,omitempty"`
HTTPStatus int `json:"-"`
}
AuthError 认证错误
func NewAuthError ¶
NewAuthError 创建认证错误
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
AuthMiddleware API认证中间件
func NewAuthMiddleware ¶
func NewAuthMiddleware(opts Options) *AuthMiddleware
NewAuthMiddleware 创建新的认证中间件
func (*AuthMiddleware) AdminAuth ¶ added in v0.0.7
func (m *AuthMiddleware) AdminAuth() gin.HandlerFunc
AdminAuth 管理员认证中间件
func (*AuthMiddleware) Authenticate ¶
func (m *AuthMiddleware) Authenticate(errorHandler ...ErrorHandler) gin.HandlerFunc
Authenticate 认证中间件处理函数
func (*AuthMiddleware) JWTAuth ¶ added in v0.0.7
func (m *AuthMiddleware) JWTAuth() gin.HandlerFunc
JWTAuth JWT 认证中间件
func (*AuthMiddleware) RefreshAppCache ¶ added in v0.0.8
func (m *AuthMiddleware) RefreshAppCache()
RefreshAppCache 刷新应用配置缓存 当动态添加或更新应用配置时调用此方法
func (*AuthMiddleware) WithConfig ¶
func (m *AuthMiddleware) WithConfig(config *Config) *AuthMiddleware
WithConfig 设置配置
func (*AuthMiddleware) WithJWT ¶ added in v0.0.7
func (m *AuthMiddleware) WithJWT(jwtService *JWTService) *AuthMiddleware
WithJWT 设置 JWT 服务
func (*AuthMiddleware) WithLogger ¶
func (m *AuthMiddleware) WithLogger(logger Logger) *AuthMiddleware
WithLogger 设置日志
type Claims ¶ added in v0.0.7
type Claims struct {
UserID uint64 `json:"user_id"` // 用户ID
Username string `json:"username"` // 用户名
Role string `json:"role,omitempty"` // 角色(如 admin, user)
AppID string `json:"app_id,omitempty"` // 应用ID
Type TokenType `json:"type"` // Token 类型
Custom map[string]interface{} `json:"custom,omitempty"` // 自定义字段
jwt.RegisteredClaims
}
Claims JWT Claims
type Client ¶
type Client struct {
BaseURL string
AppID string
AppSecret string
HTTPClient *http.Client
Debug bool // 调试模式
Logger Logger // 日志接口
}
Client API认证客户端
func NewClient ¶
func NewClient(baseURL, appID, appSecret string, opts ...ClientOption) *Client
NewClient 创建新的API客户端
func (*Client) DeleteJSON ¶
DeleteJSON 发送DELETE请求并解析JSON响应
func (*Client) Post ¶
func (c *Client) Post(path string, body interface{}, headers ...map[string]string) (*http.Response, error)
Post 发送POST请求
func (*Client) Put ¶
func (c *Client) Put(path string, body interface{}, headers ...map[string]string) (*http.Response, error)
Put 发送PUT请求
type ClientOption ¶
type ClientOption func(*Client)
ClientOption 客户端配置选项
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient 自定义HTTP客户端
type Config ¶
type Config struct {
Apps map[string]*AppConfig `json:"apps" yaml:"apps"` // 应用配置映射
TimestampTolerance int64 `json:"timestamp_tolerance" yaml:"timestamp_tolerance"` // 时间戳容差(秒)
DefaultRateLimit int `json:"default_rate_limit" yaml:"default_rate_limit"` // 默认速率限制
EnableIPCheck bool `json:"enable_ip_check" yaml:"enable_ip_check"` // 是否启用IP检查
JWT *JWTConfig `json:"jwt,omitempty" yaml:"jwt,omitempty"` // JWT 配置(可选)
TokenBlacklist *TokenBlacklistConfig `json:"token_blacklist,omitempty" yaml:"token_blacklist,omitempty"` // Token 黑名单配置(可选)
// contains filtered or unexported fields
}
Config 认证配置管理器
func (*Config) GetEnabledAppCount ¶
GetEnabledAppCount 获取启用的应用数量
func (*Config) LoadFromJSON ¶
LoadFromJSON 从JSON文件加载配置
func (*Config) LoadFromYAML ¶
LoadFromYAML 从YAML文件加载配置
func (*Config) SaveToJSON ¶
SaveToJSON 保存配置到JSON文件
func (*Config) SaveToYAML ¶
SaveToYAML 保存配置到YAML文件
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
ConfigBuilder 配置构建器
func (*ConfigBuilder) AddApp ¶
func (b *ConfigBuilder) AddApp(app *AppConfig) *ConfigBuilder
AddApp 添加应用
func (*ConfigBuilder) AddSimpleApp ¶
func (b *ConfigBuilder) AddSimpleApp(appID, appSecret, appName string) *ConfigBuilder
AddSimpleApp 添加简单应用配置
func (*ConfigBuilder) MustBuild ¶
func (b *ConfigBuilder) MustBuild() *Config
MustBuild 构建配置(失败则panic)
func (*ConfigBuilder) SetDefaultRateLimit ¶
func (b *ConfigBuilder) SetDefaultRateLimit(limit int) *ConfigBuilder
SetDefaultRateLimit 设置默认速率限制
func (*ConfigBuilder) SetEnableIPCheck ¶
func (b *ConfigBuilder) SetEnableIPCheck(enabled bool) *ConfigBuilder
SetEnableIPCheck 设置是否启用IP检查
func (*ConfigBuilder) SetTimestampTolerance ¶
func (b *ConfigBuilder) SetTimestampTolerance(seconds int64) *ConfigBuilder
SetTimestampTolerance 设置时间戳容差
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption 配置选项函数
func WithDefaultRateLimit ¶
func WithDefaultRateLimit(limit int) ConfigOption
WithDefaultRateLimit 设置默认速率限制
func WithTimestampTolerance ¶
func WithTimestampTolerance(seconds int64) ConfigOption
WithTimestampTolerance 设置时间戳容差
type ErrorCode ¶
type ErrorCode string
ErrorCode 错误代码
const ( // 认证相关错误 ErrCodeInvalidParams ErrorCode = "INVALID_PARAMS" // 参数无效 ErrCodeAppNotFound ErrorCode = "APP_NOT_FOUND" // 应用不存在 ErrCodeAppDisabled ErrorCode = "APP_DISABLED" // 应用已禁用 ErrCodeInvalidTimestamp ErrorCode = "INVALID_TIMESTAMP" // 时间戳无效 ErrCodeInvalidSign ErrorCode = "INVALID_SIGN" // 签名无效 ErrCodeIPNotAllowed ErrorCode = "IP_NOT_ALLOWED" // IP不在白名单 ErrCodeRateLimitExceeded ErrorCode = "RATE_LIMIT_EXCEEDED" // 超过速率限制 ErrCodeForbidden ErrorCode = "FORBIDDEN" // 禁止访问 // 系统错误 ErrCodeInternalError ErrorCode = "INTERNAL_ERROR" // 内部错误 ErrCodeConfigError ErrorCode = "CONFIG_ERROR" // 配置错误 )
type ErrorHandler ¶
ErrorHandler 错误处理函数
type ErrorResponse ¶
type ErrorResponse struct {
Success bool `json:"success"`
Error *AuthError `json:"error"`
Timestamp int64 `json:"timestamp"`
RequestID string `json:"request_id,omitempty"`
}
ErrorResponse 标准错误响应格式
func NewErrorResponse ¶
func NewErrorResponse(err *AuthError, requestID string) *ErrorResponse
NewErrorResponse 创建错误响应
type InMemoryBlacklist ¶ added in v0.0.7
type InMemoryBlacklist struct {
// contains filtered or unexported fields
}
InMemoryBlacklist 基于内存的黑名单实现
func NewInMemoryBlacklist ¶ added in v0.0.7
func NewInMemoryBlacklist() *InMemoryBlacklist
NewInMemoryBlacklist 创建内存黑名单
func NewInMemoryBlacklistWithCleanup ¶ added in v0.0.7
func NewInMemoryBlacklistWithCleanup(interval time.Duration) *InMemoryBlacklist
NewInMemoryBlacklistWithCleanup 创建带自动清理的内存黑名单
func (*InMemoryBlacklist) Add ¶ added in v0.0.7
func (b *InMemoryBlacklist) Add(tokenHash string, expiry time.Time) error
Add 添加 Token 到黑名单
func (*InMemoryBlacklist) Cleanup ¶ added in v0.0.7
func (b *InMemoryBlacklist) Cleanup() error
Cleanup 清理过期的黑名单记录
func (*InMemoryBlacklist) Count ¶ added in v0.0.7
func (b *InMemoryBlacklist) Count() int
Count 获取黑名单中的 Token 数量
func (*InMemoryBlacklist) GetExpiry ¶ added in v0.0.7
func (b *InMemoryBlacklist) GetExpiry(tokenHash string) (time.Time, bool)
GetExpiry 获取 Token 的过期时间
func (*InMemoryBlacklist) IsBlacklisted ¶ added in v0.0.7
func (b *InMemoryBlacklist) IsBlacklisted(tokenHash string) bool
IsBlacklisted 检查 Token 是否在黑名单中
func (*InMemoryBlacklist) StartAutoCleanup ¶ added in v0.0.7
func (b *InMemoryBlacklist) StartAutoCleanup(interval time.Duration)
StartAutoCleanup 启动自动清理
func (*InMemoryBlacklist) StopAutoCleanup ¶ added in v0.0.7
func (b *InMemoryBlacklist) StopAutoCleanup()
StopAutoCleanup 停止自动清理
type JWTConfig ¶ added in v0.0.7
type JWTConfig struct {
SecretKey string `yaml:"secret_key" json:"secret_key"` // JWT 密钥
Issuer string `yaml:"issuer" json:"issuer"` // 签发者
AccessExpiry time.Duration `yaml:"access_expiry" json:"access_expiry"` // Access Token 有效期
RefreshExpiry time.Duration `yaml:"refresh_expiry" json:"refresh_expiry"` // Refresh Token 有效期
}
JWTConfig JWT 配置
func DefaultJWTConfig ¶ added in v0.0.7
func DefaultJWTConfig() JWTConfig
DefaultJWTConfig 默认 JWT 配置
type JWTService ¶ added in v0.0.7
type JWTService struct {
// contains filtered or unexported fields
}
JWTService JWT 服务
func NewJWTService ¶ added in v0.0.7
func NewJWTService(config JWTConfig) *JWTService
NewJWTService 创建 JWT 服务
func (*JWTService) GenerateAccessToken ¶ added in v0.0.7
func (s *JWTService) GenerateAccessToken(userID uint64, username, role, appID string, custom map[string]interface{}) (string, error)
GenerateAccessToken 生成 Access Token
func (*JWTService) GenerateRefreshToken ¶ added in v0.0.7
func (s *JWTService) GenerateRefreshToken(userID uint64, username string) (string, error)
GenerateRefreshToken 生成 Refresh Token
func (*JWTService) GenerateTokenPair ¶ added in v0.0.7
func (s *JWTService) GenerateTokenPair(userID uint64, username, role, appID string, custom map[string]interface{}) (*TokenPair, error)
GenerateTokenPair 生成 Token 对
func (*JWTService) GetConfig ¶ added in v0.0.7
func (s *JWTService) GetConfig() JWTConfig
GetConfig 获取配置
func (*JWTService) ParseToken ¶ added in v0.0.7
func (s *JWTService) ParseToken(tokenString string) (*Claims, error)
ParseToken 解析并验证 Token
func (*JWTService) RefreshAccessToken ¶ added in v0.0.7
func (s *JWTService) RefreshAccessToken(refreshToken string, role, appID string, custom map[string]interface{}) (string, error)
RefreshAccessToken 刷新 Access Token
func (*JWTService) RevokeToken ¶ added in v0.0.7
func (s *JWTService) RevokeToken(tokenString string) error
RevokeToken 撤销 Token(加入黑名单)
func (*JWTService) ValidateAccessToken ¶ added in v0.0.7
func (s *JWTService) ValidateAccessToken(tokenString string) (*Claims, error)
ValidateAccessToken 验证 Access Token
func (*JWTService) ValidateRefreshToken ¶ added in v0.0.7
func (s *JWTService) ValidateRefreshToken(tokenString string) (*Claims, error)
ValidateRefreshToken 验证 Refresh Token
func (*JWTService) WithBlacklist ¶ added in v0.0.7
func (s *JWTService) WithBlacklist(blacklist TokenBlacklist) *JWTService
WithBlacklist 设置 Token 黑名单
type Logger ¶
type Logger interface {
Info(msg string, fields ...interface{})
Error(msg string, fields ...interface{})
Debug(msg string, fields ...interface{})
}
Logger 日志接口
type Options ¶
type Options struct {
Config *Config
Logger Logger
ErrorHandler ErrorHandler
}
Options 中间件选项
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter 速率限制器
type RedisConfig ¶ added in v0.0.7
type RedisConfig struct {
Addr string `yaml:"addr" json:"addr"` // Redis 地址
Password string `yaml:"password" json:"password"` // Redis 密码
DB int `yaml:"db" json:"db"` // Redis 数据库
}
RedisConfig Redis 配置
type SuccessResponse ¶
type SuccessResponse struct {
Success bool `json:"success"`
Data interface{} `json:"data"`
Timestamp int64 `json:"timestamp"`
RequestID string `json:"request_id,omitempty"`
}
SuccessResponse 标准成功响应格式
func NewSuccessResponse ¶
func NewSuccessResponse(data interface{}, requestID string) *SuccessResponse
NewSuccessResponse 创建成功响应
type TokenBlacklist ¶ added in v0.0.7
type TokenBlacklist interface {
// Add 添加 Token 到黑名单
Add(tokenHash string, expiry time.Time) error
// IsBlacklisted 检查 Token 是否在黑名单中
IsBlacklisted(tokenHash string) bool
// Cleanup 清理过期的黑名单记录
Cleanup() error
// Count 获取黑名单中的 Token 数量
Count() int
}
TokenBlacklist Token 黑名单接口
type TokenBlacklistConfig ¶ added in v0.0.7
type TokenBlacklistConfig struct {
Type string `yaml:"type" json:"type"` // blacklist 类型: memory, redis
CleanupInterval time.Duration `yaml:"cleanup_interval" json:"cleanup_interval"` // 清理间隔
// Redis 配置(如果使用 Redis)
Redis RedisConfig `yaml:"redis" json:"redis"`
}
TokenBlacklistConfig Token 黑名单配置
func DefaultTokenBlacklistConfig ¶ added in v0.0.7
func DefaultTokenBlacklistConfig() TokenBlacklistConfig
DefaultTokenBlacklistConfig 默认黑名单配置