Files
tokens-reef/backend/internal/config/auth.go
2026-04-24 08:32:16 +08:00

44 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
// JWTConfig JWT 认证配置
type JWTConfig struct {
Secret string `mapstructure:"secret"`
SecretConfigured bool `mapstructure:"-"` // 是否手动配置(非启动期自动生成/补齐)
ExpireHour int `mapstructure:"expire_hour"`
// AccessTokenExpireMinutes: Access Token有效期分钟
// - >0: 使用分钟配置(优先级高于 ExpireHour
// - =0: 回退使用 ExpireHour向后兼容旧配置
AccessTokenExpireMinutes int `mapstructure:"access_token_expire_minutes"`
// RefreshTokenExpireDays: Refresh Token有效期默认30天
RefreshTokenExpireDays int `mapstructure:"refresh_token_expire_days"`
// RefreshWindowMinutes: 刷新窗口分钟在Access Token过期前多久开始允许刷新
RefreshWindowMinutes int `mapstructure:"refresh_window_minutes"`
}
// TotpConfig TOTP 双因素认证配置
type TotpConfig struct {
EncryptionKey string `mapstructure:"encryption_key"` // AES-256 密钥32 字节 hex 编码)
EncryptionKeyConfigured bool `mapstructure:"-"` // 是否手动配置(非自动生成)
}
// TurnstileConfig Cloudflare Turnstile 验证配置
type TurnstileConfig struct {
Required bool `mapstructure:"required"`
}
// DefaultConfig 默认值配置
type DefaultConfig struct {
AdminEmail string `mapstructure:"admin_email"`
AdminPassword string `mapstructure:"admin_password"`
UserConcurrency int `mapstructure:"user_concurrency"`
UserBalance float64 `mapstructure:"user_balance"`
APIKeyPrefix string `mapstructure:"api_key_prefix"`
RateMultiplier float64 `mapstructure:"rate_multiplier"`
}
// RateLimitConfig 限流配置
type RateLimitConfig struct {
OverloadCooldownMinutes int `mapstructure:"overload_cooldown_minutes"`
OAuth401CooldownMinutes int `mapstructure:"oauth_401_cooldown_minutes"`
}