1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Security配置

use crate::tina::{data::AppResult, server::application::AppConfig};

use super::UpdateableConfig;

/// Security
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(crate = "serde")]
pub struct SecurityConfig {
    /// Security Token Header名称
    pub token_header_name: String,
    /// Security Token密钥
    pub token_secret: String,
    /// Security Token过期时间(分钟)
    pub token_expire_time: u32,
}

impl Default for SecurityConfig {
    fn default() -> Self {
        Self {
            token_header_name: "Authorization".to_owned(),
            token_secret: "abcdefghijklmnopqrstuvwxyz".to_owned(),
            token_expire_time: 30,
        }
    }
}

/// 可应用的配置
#[async_trait]
impl UpdateableConfig for SecurityConfig {
    /// 应用更新
    async fn apply(&self, _application: &AppConfig) -> AppResult<()> {
        Ok(())
    }
}