feat(server): 配置签名 URL 密钥 — StorageConfig.secret_key

This commit is contained in:
iven
2026-05-10 15:39:11 +08:00
parent 1a459de4ad
commit 85bff6f267
3 changed files with 23 additions and 3 deletions

View File

@@ -127,6 +127,20 @@ pub struct StorageConfig {
pub upload_dir: String,
/// 单文件最大大小(如 "10MB"
pub max_file_size: String,
/// 签名 URL 密钥HMAC-SHA256
#[serde(default = "default_secret_key")]
pub secret_key: String,
}
fn default_secret_key() -> String {
#[cfg(debug_assertions)]
{
"dev-only-secret-key-change-in-production".to_string()
}
#[cfg(not(debug_assertions))]
{
panic!("ERP__STORAGE__SECRET_KEY 必须设置(生产环境不允许使用默认签名密钥)")
}
}
impl StorageConfig {