update
This commit is contained in:
@ -84,8 +84,9 @@ func (d DatabaseConfig) Addr() string {
|
||||
|
||||
// JWTConfig 令牌签发配置。
|
||||
type JWTConfig struct {
|
||||
Secret string `yaml:"secret"`
|
||||
ExpireHours int `yaml:"expire_hours"`
|
||||
Secret string `yaml:"secret"`
|
||||
ExpireHours int `yaml:"expire_hours"` // access token 有效期(小时)
|
||||
RefreshExpireHours int `yaml:"refresh_expire_hours"` // refresh token 有效期(小时)
|
||||
}
|
||||
|
||||
// UploadConfig 图片静态资源配置。
|
||||
@ -145,8 +146,9 @@ func defaultConfig() *Config {
|
||||
ConnMaxLifetime: 3600,
|
||||
},
|
||||
JWT: JWTConfig{
|
||||
Secret: "dev-secret-change-me-fashion-2026",
|
||||
ExpireHours: 168,
|
||||
Secret: "dev-secret-change-me-fashion-2026",
|
||||
ExpireHours: 2, // access token 2 小时(短命,泄漏窗口小)
|
||||
RefreshExpireHours: 720, // refresh token 30 天(长命,落库可吊销)
|
||||
},
|
||||
Upload: UploadConfig{
|
||||
Dir: "./uploads",
|
||||
@ -238,6 +240,7 @@ func (c *Config) applyEnv() {
|
||||
|
||||
envStr("JWT_SECRET", &c.JWT.Secret)
|
||||
envInt("JWT_EXPIRE_HOURS", &c.JWT.ExpireHours)
|
||||
envInt("JWT_REFRESH_EXPIRE_HOURS", &c.JWT.RefreshExpireHours)
|
||||
|
||||
envBool("CLIENT_SIGN_ENABLED", &c.ClientSign.Enabled)
|
||||
envStr("CLIENT_SIGN_SECRET", &c.ClientSign.Secret)
|
||||
@ -272,6 +275,9 @@ func (c *Config) normalize() {
|
||||
if c.JWT.ExpireHours <= 0 {
|
||||
c.JWT.ExpireHours = 168
|
||||
}
|
||||
if c.JWT.RefreshExpireHours <= 0 {
|
||||
c.JWT.RefreshExpireHours = 720
|
||||
}
|
||||
if c.Upload.Dir == "" {
|
||||
c.Upload.Dir = "./uploads"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user