admin_config/
auth_config.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct AuthConfig {
5    /// JWT 密钥
6    pub token_secret: String,
7    /// Token 过期时间(小时)
8    pub token_expiry_hours: u64,
9    /// Refresh Token 过期时间(天)
10    pub refresh_token_expiry_days: u64,
11}
12
13impl Default for AuthConfig {
14    fn default() -> Self {
15        Self {
16            token_secret: "".to_string(),
17            token_expiry_hours: 24,
18            refresh_token_expiry_days: 7,
19        }
20    }
21}
22
23impl AuthConfig {
24    pub fn token_expiry_seconds(&self) -> u64 {
25        self.token_expiry_hours * 3600
26    }
27
28    pub fn refresh_token_expiry_seconds(&self) -> u64 {
29        self.refresh_token_expiry_days * 86400
30    }
31}