#[non_exhaustive]pub struct JwtValidationOptions {
pub algorithms: BTreeSet<JwsAlgorithm>,
pub typ: Option<String>,
pub issuer: Option<String>,
pub audience: Option<String>,
pub role: KeyRole,
pub issuer_binding: IssuerBinding,
pub required_claims: BTreeSet<String>,
pub now: Option<i64>,
pub leeway: Duration,
}Expand description
Options of JwtValidator: what the token must be, and when.
The default accepts every algorithm the crate verifies, any typ, any issuer and audience,
with the key bound to iss, at the current time without leeway, and requires no claim.
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.algorithms: BTreeSet<JwsAlgorithm>The algorithms accepted; every algorithm when empty.
typ: Option<String>The header typ the token must have, if any.
issuer: Option<String>The iss the token must have, if any.
audience: Option<String>The audience the token’s aud must include, if any.
role: KeyRoleThe role the signing key is resolved for: KeyRole::Issuer (assertionMethod in a
DID document) by default, KeyRole::Subject (authentication) for a token that
proves possession.
issuer_binding: IssuerBindingWhether the signing key must belong to iss.
required_claims: BTreeSet<String>Claims that must be present, registered or not.
now: Option<i64>The validation time in seconds since the Unix epoch; the current time when None.
leeway: DurationHow far exp, nbf and iat may miss the validation time and still pass.
Implementations§
Source§impl JwtValidationOptions
impl JwtValidationOptions
Sourcepub fn with_algorithm(self, alg: JwsAlgorithm) -> Self
pub fn with_algorithm(self, alg: JwsAlgorithm) -> Self
These options also accepting alg. Once one algorithm is named, only the named ones
are accepted.
Sourcepub fn with_typ(self, typ: impl Into<String>) -> Self
pub fn with_typ(self, typ: impl Into<String>) -> Self
These options requiring the header typ to be typ.
Sourcepub fn with_issuer(self, issuer: impl Into<String>) -> Self
pub fn with_issuer(self, issuer: impl Into<String>) -> Self
These options requiring iss to be issuer.
Sourcepub fn with_audience(self, audience: impl Into<String>) -> Self
pub fn with_audience(self, audience: impl Into<String>) -> Self
These options requiring aud to include audience.
Sourcepub fn with_role(self, role: KeyRole) -> Self
pub fn with_role(self, role: KeyRole) -> Self
These options resolving the signing key for role.
Sourcepub fn with_issuer_binding(self, binding: IssuerBinding) -> Self
pub fn with_issuer_binding(self, binding: IssuerBinding) -> Self
These options with binding.
Sourcepub fn with_required_claims<I, S>(self, claims: I) -> Self
pub fn with_required_claims<I, S>(self, claims: I) -> Self
These options also requiring every claim of claims.
Sourcepub fn at(self, now: i64) -> Self
pub fn at(self, now: i64) -> Self
These options validating at now, in seconds since the Unix epoch.
Sourcepub fn with_leeway(self, leeway: Duration) -> Self
pub fn with_leeway(self, leeway: Duration) -> Self
These options with leeway.
Trait Implementations§
Source§impl Clone for JwtValidationOptions
impl Clone for JwtValidationOptions
Source§impl Debug for JwtValidationOptions
impl Debug for JwtValidationOptions
Source§impl Default for JwtValidationOptions
impl Default for JwtValidationOptions
impl Eq for JwtValidationOptions
Source§impl PartialEq for JwtValidationOptions
impl PartialEq for JwtValidationOptions
impl StructuralPartialEq for JwtValidationOptions
Auto Trait Implementations§
impl Freeze for JwtValidationOptions
impl RefUnwindSafe for JwtValidationOptions
impl Send for JwtValidationOptions
impl Sync for JwtValidationOptions
impl Unpin for JwtValidationOptions
impl UnsafeUnpin for JwtValidationOptions
impl UnwindSafe for JwtValidationOptions
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.