pub struct JwtConfig {
pub secret: String,
pub algorithm: JwtAlgorithm,
pub issuer: Option<String>,
pub audience: Option<String>,
pub access_token_ttl: Duration,
pub refresh_token_ttl: Duration,
pub validate_issuer: bool,
pub validate_audience: bool,
pub leeway_seconds: i64,
}Expand description
JWT 配置
Fields§
§secret: String签名密钥
algorithm: JwtAlgorithm签名算法
issuer: Option<String>签发者
audience: Option<String>受众
access_token_ttl: Duration访问令牌有效期
refresh_token_ttl: Duration刷新令牌有效期
validate_issuer: bool是否验证签发者
validate_audience: bool是否验证受众
leeway_seconds: i64时钟偏移容忍度(秒)
Implementations§
Source§impl JwtConfig
impl JwtConfig
Sourcepub fn with_algorithm(self, algorithm: JwtAlgorithm) -> Self
pub fn with_algorithm(self, algorithm: JwtAlgorithm) -> Self
设置签名算法
Sourcepub fn with_issuer(self, issuer: impl Into<String>) -> Self
pub fn with_issuer(self, issuer: impl Into<String>) -> Self
设置签发者
Sourcepub fn with_audience(self, audience: impl Into<String>) -> Self
pub fn with_audience(self, audience: impl Into<String>) -> Self
设置受众
Sourcepub fn with_access_token_ttl(self, ttl: Duration) -> Self
pub fn with_access_token_ttl(self, ttl: Duration) -> Self
设置访问令牌有效期
Sourcepub fn with_refresh_token_ttl(self, ttl: Duration) -> Self
pub fn with_refresh_token_ttl(self, ttl: Duration) -> Self
设置刷新令牌有效期
Sourcepub fn with_leeway(self, seconds: i64) -> Self
pub fn with_leeway(self, seconds: i64) -> Self
设置时钟偏移容忍度
Sourcepub fn access_token_expires_in(&self) -> i64
pub fn access_token_expires_in(&self) -> i64
获取访问令牌过期时间(秒)
Sourcepub fn refresh_token_expires_in(&self) -> i64
pub fn refresh_token_expires_in(&self) -> i64
获取刷新令牌过期时间(秒)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JwtConfig
impl RefUnwindSafe for JwtConfig
impl Send for JwtConfig
impl Sync for JwtConfig
impl Unpin for JwtConfig
impl UnsafeUnpin for JwtConfig
impl UnwindSafe for JwtConfig
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