44 lines
1.8 KiB
Go
44 lines
1.8 KiB
Go
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"`
|
||
}
|