pub struct SecurityConfig {
pub aes_key: String,
pub aes_iv: String,
pub api_key_encrypt_key: String,
pub password_salt: String,
pub enable_cors: bool,
pub allowed_origins: String,
pub enable_csrf: bool,
}Expand description
安全配置
包含加密密钥、跨域配置、CSRF 防护等安全相关设置
§字段说明
aes_key: AES-256 加密密钥(64位十六进制,32字节)aes_iv: AES 初始化向量(32位十六进制,16字节)api_key_encrypt_key: API 密钥加密密钥(64位十六进制,32字节)password_salt: 密码加密盐值enable_cors: 是否启用跨域资源共享allowed_origins: 允许的来源域名(逗号分隔)enable_csrf: 是否启用 CSRF 防护
§示例
use admin_config::SecurityConfig;
let config = SecurityConfig::default();
assert_eq!(config.aes_key.len(), 64);
assert_eq!(config.aes_iv.len(), 32);
assert!(config.enable_cors);Fields§
§aes_key: StringAES 密钥(64位十六进制,32字节)
aes_iv: StringAES 向量(32位十六进制,16字节)
api_key_encrypt_key: StringAPI 密钥加密密钥(64位十六进制,32字节,用于 AES-256-GCM)
password_salt: String密码加密盐值
enable_cors: bool是否启用 CORS
allowed_origins: String允许的来源(逗号分隔)
enable_csrf: bool是否启用 CSRF 防护
Implementations§
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecurityConfig
impl Debug for SecurityConfig
Source§impl Default for SecurityConfig
impl Default for SecurityConfig
Source§impl<'de> Deserialize<'de> for SecurityConfig
impl<'de> Deserialize<'de> for SecurityConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SecurityConfig
impl RefUnwindSafe for SecurityConfig
impl Send for SecurityConfig
impl Sync for SecurityConfig
impl Unpin for SecurityConfig
impl UnwindSafe for SecurityConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more