feat(server): 配置签名 URL 密钥 — StorageConfig.secret_key
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user