pub struct AuthConfig {
pub token_secret: String,
pub token_expiry_hours: u64,
pub refresh_token_expiry_days: u64,
}Expand description
认证配置
用于配置 JWT Token 的密钥和过期时间
§字段说明
token_secret: JWT 签名密钥,默认自动生成 32 字节随机密钥token_expiry_hours: Access Token 过期时间(小时),默认 24 小时refresh_token_expiry_days: Refresh Token 过期时间(天),默认 7 天
§示例
use admin_config::AuthConfig;
let config = AuthConfig::default();
assert_eq!(config.token_expiry_hours, 24);
assert_eq!(config.refresh_token_expiry_days, 7);Fields§
§token_secret: StringJWT 密钥
token_expiry_hours: u64Token 过期时间(小时)
refresh_token_expiry_days: u64Refresh Token 过期时间(天)
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn token_expiry_seconds(&self) -> u64
pub fn token_expiry_seconds(&self) -> u64
获取 Token 过期时间(秒)
Sourcepub fn refresh_token_expiry_seconds(&self) -> u64
pub fn refresh_token_expiry_seconds(&self) -> u64
获取 Refresh Token 过期时间(秒)
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
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 AuthConfig
impl Debug for AuthConfig
Source§impl Default for AuthConfig
impl Default for AuthConfig
Source§impl<'de> Deserialize<'de> for AuthConfig
impl<'de> Deserialize<'de> for AuthConfig
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 AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnwindSafe for AuthConfig
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