#[non_exhaustive]pub struct AuthConfig {Show 15 fields
pub jwt_secret: Option<String>,
pub jwt_algorithm: JwtAlgorithm,
pub jwt_issuer: Option<String>,
pub jwt_audience: Option<String>,
pub access_token_ttl: Option<DurationStr>,
pub refresh_token_ttl: Option<DurationStr>,
pub jwks_url: Option<String>,
pub jwks_cache_ttl: DurationStr,
pub session_ttl: DurationStr,
pub jwt_leeway: DurationStr,
pub audience_required: bool,
pub required_claims: Vec<String>,
pub session_cookie_ttl: Option<DurationStr>,
pub jwks_require_kid: bool,
pub legacy_secrets: Vec<LegacySecret>,
}Expand description
Authentication configuration.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.jwt_secret: Option<String>Required for HS256.
jwt_algorithm: JwtAlgorithm§jwt_issuer: Option<String>If set, tokens with a different issuer are rejected.
jwt_audience: Option<String>If set, tokens with a different audience are rejected.
access_token_ttl: Option<DurationStr>Access token lifetime (e.g., “15m”, “1h”). Used by ctx.issue_token_pair().
refresh_token_ttl: Option<DurationStr>Refresh token lifetime (e.g., “7d”, “30d”). Used by ctx.issue_token_pair().
jwks_url: Option<String>Required for RS256; keys are fetched and cached automatically.
jwks_cache_ttl: DurationStrJWKS cache TTL duration (e.g. “1h”, “30m”).
session_ttl: DurationStrSession TTL duration (e.g. “7d”, “24h”). Used for WebSocket sessions.
jwt_leeway: DurationStrClock-skew tolerance for exp / nbf validation (e.g. “60s”, “5m”).
Sites with NTP-synchronized clocks can drop this to “5s”; older deployments
or clients with drifting clocks may need higher. Defaults to “60s”.
audience_required: boolWhen true (default), jwt_audience must be set when auth is enabled.
Set to false only during migration.
required_claims: Vec<String>JWT spec claims that must be present in every token.
Defaults to ["exp", "sub"]. Add "aud" here for claim-level
enforcement in addition to the jwt_audience equality check.
Used for OAuth consent flow cookies. Defaults to the access token TTL.
jwks_require_kid: boolReject RS256 tokens that arrive without a kid header.
Default: true. On shared issuers (Firebase, Clerk multi-app) a kidless
token would validate against an arbitrary cached key, accepting tokens
signed by any app the issuer exposes. Set to false only for providers
that genuinely omit kid in token headers (rare).
legacy_secrets: Vec<LegacySecret>Old HMAC secrets still accepted for validation (never for signing).
Each entry carries a mandatory valid_until timestamp; expired entries
are silently dropped at middleware construction.
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn access_token_ttl_secs(&self) -> i64
pub fn access_token_ttl_secs(&self) -> i64
Resolved access token TTL in seconds. Minimum 1 to prevent zero-lifetime tokens.
Sourcepub fn refresh_token_ttl_days(&self) -> i64
pub fn refresh_token_ttl_days(&self) -> i64
Resolved refresh token TTL in days. Default 30; sub-day values floor to 1.
Resolved session cookie TTL in seconds. Falls back to access_token_ttl_secs().
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Returns true when any credential or claim validation field is set.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more