pub struct JwtProvider {
pub name: String,
pub jwks_url: String,
pub trusted_ca_file: Option<String>,
pub issuer: Option<String>,
pub audience: Option<String>,
pub algorithms: Vec<String>,
pub refresh_secs: u64,
pub leeway_secs: u64,
pub consumer: Option<String>,
pub retired_key_grace_secs: Option<u64>,
pub stale_on_error_secs: Option<u64>,
}Expand description
One JWT verification provider (DW-019).
Fields§
§name: String§jwks_url: StringJWKS endpoint (http:// or https://). Keys are fetched lazily on
the first Bearer request, refreshed after refresh_secs, and
re-fetched on an unknown kid (key rotation mid-flight).
trusted_ca_file: Option<String>Path to a PEM file of CA certificates the JWKS fetcher trusts for
its https:// connection INSTEAD of the default public (webpki)
root set (#121): for JWKS endpoints served over TLS by a private
CA. The file may carry several certificates (a typical CA bundle).
Only meaningful with an https:// jwks_url — no TLS is negotiated
toward an http:// endpoint, so validation rejects that
combination. The file must exist and be readable at config compile
time; validation names this field otherwise.
issuer: Option<String>Required token issuer (iss claim). Absent: any issuer accepted.
audience: Option<String>Required audience (aud claim). Audience is validated ONLY when
this is configured (#124, maintainer decision): a provider
without an audience ACCEPTS tokens that carry any (or no) aud
claim — aud is not interpreted unless the provider names one.
All other validations (exp, nbf, iss when configured, the
algorithm allowlist) are identical either way.
algorithms: Vec<String>Allowed signature algorithms (default ["RS256", "ES256"]).
none and HMAC (HS*) algorithms are never allowed implicitly —
they must not appear in this list; validation rejects them
(asymmetric verification only: the gateway holds no shared
secrets with issuers).
refresh_secs: u64JWKS cache staleness bound in seconds (default 300): a cached key set older than this is refreshed before use.
leeway_secs: u64exp/nbf clock-skew leeway in seconds (default 30).
consumer: Option<String>Consumer this provider’s tokens authenticate. Absent: the token’s
iss claim is matched against consumers’ jwt credentials.
retired_key_grace_secs: Option<u64>How long a key REMOVED from a fresh JWKS fetch keeps verifying
(DW-046), in seconds (default 86400 = 24 h; 0 disables). The
dual-validity window for JWKS rotation: issuers drop the old
key from their JWKS the moment the new one appears, while
previously-issued tokens still carry the old kid — during
this grace the gateway honors the immediately-previous key set
for kids the fresh set no longer carries. Only ONE previous set
is retained (rotation is one step at a time). Validation caps
the value at 7 days (604800).
stale_on_error_secs: Option<u64>How long to serve stale (cached) keys after a JWKS fetch failure
(SEC-12, #215), in seconds (default: same as refresh_secs,
capped at 300). When a JWKS fetch fails, the cached key set
keeps serving for this duration before a new fetch is attempted,
so a transient JWKS provider outage does not cascade into auth
failures. 0 disables stale-on-error (a fetch failure surfaces
immediately when the cache is empty; when the cache is non-empty
the existing degraded-mode behavior applies).
Implementations§
Source§impl JwtProvider
impl JwtProvider
Sourcepub fn retired_key_grace_secs(&self) -> u64
pub fn retired_key_grace_secs(&self) -> u64
retired_key_grace_secs resolved to its effective value
(default 86 400; the DW-046 dual-validity window).
Sourcepub fn stale_on_error_secs(&self) -> u64
pub fn stale_on_error_secs(&self) -> u64
stale_on_error_secs resolved to its effective value (SEC-12,
#215): the default is min(refresh_secs, 300) — a failed fetch
backs off for at most one refresh interval (capped at 5 min) so
a down JWKS endpoint does not chain every Bearer request through
a doomed fetch attempt.
Trait Implementations§
Source§impl Clone for JwtProvider
impl Clone for JwtProvider
Source§fn clone(&self) -> JwtProvider
fn clone(&self) -> JwtProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JwtProvider
impl Debug for JwtProvider
Source§impl<'de> Deserialize<'de> for JwtProvider
impl<'de> Deserialize<'de> for JwtProvider
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>,
Source§impl JsonSchema for JwtProvider
impl JsonSchema for JwtProvider
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for JwtProvider
impl PartialEq for JwtProvider
Source§impl Serialize for JwtProvider
impl Serialize for JwtProvider
impl StructuralPartialEq for JwtProvider
Auto Trait Implementations§
impl Freeze for JwtProvider
impl RefUnwindSafe for JwtProvider
impl Send for JwtProvider
impl Sync for JwtProvider
impl Unpin for JwtProvider
impl UnwindSafe for JwtProvider
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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