pub struct ValidationOptions {
pub leeway: u64,
pub validate_exp: bool,
pub validate_nbf: bool,
pub audiences: Option<HashSet<String>>,
pub issuer: Option<String>,
pub subject: Option<String>,
pub algorithms: HashSet<Algorithm>,
pub required_claims: Option<HashSet<String>>,
}
Fields§
§leeway: u64
General leeway (in seconds) applied to all time-related claims like exp
, nbf
, and iat
.
validate_exp: bool
Validate the expiration time (exp
claim).
validate_nbf: bool
Validate the not-before time (nbf
claim).
audiences: Option<HashSet<String>>
Set of acceptable audience members.
issuer: Option<String>
Expected issuer.
subject: Option<String>
Expected subject.
algorithms: HashSet<Algorithm>
Allowed signing algorithms for the JWT.
required_claims: Option<HashSet<String>>
Required claims.
Implementations§
Source§impl ValidationOptions
impl ValidationOptions
Sourcepub fn new(alg: Algorithm) -> Self
pub fn new(alg: Algorithm) -> Self
Create a new set of ValidationOptions
with a specific algorithm.
Sourcepub fn without_expiry(self) -> Self
pub fn without_expiry(self) -> Self
Disable expiration (exp
) validation.
Sourcepub fn with_audiences<T: ToString>(self, audiences: &[T]) -> Self
pub fn with_audiences<T: ToString>(self, audiences: &[T]) -> Self
Set acceptable audience members as a HashSet of strings.
Sourcepub fn with_audience<T: ToString>(self, audience: T) -> Self
pub fn with_audience<T: ToString>(self, audience: T) -> Self
Set a single audience member as the only acceptable value.
Sourcepub fn with_issuer<T: ToString>(self, issuer: T) -> Self
pub fn with_issuer<T: ToString>(self, issuer: T) -> Self
Set the issuer claim to validate.
Sourcepub fn with_subject<T: ToString>(self, subject: T) -> Self
pub fn with_subject<T: ToString>(self, subject: T) -> Self
Set the subject claim to validate.
Sourcepub fn with_leeway(self, leeway: u64) -> Self
pub fn with_leeway(self, leeway: u64) -> Self
Set leeway for time-related claims (exp
, nbf
, iat
).
Sourcepub fn with_algorithm(self, alg: Algorithm) -> Self
pub fn with_algorithm(self, alg: Algorithm) -> Self
Add an allowed signing algorithm.
Sourcepub fn with_required_claim<T: ToString>(self, claim: T) -> Self
pub fn with_required_claim<T: ToString>(self, claim: T) -> Self
Add a required claim.
Trait Implementations§
Source§impl Clone for ValidationOptions
impl Clone for ValidationOptions
Source§fn clone(&self) -> ValidationOptions
fn clone(&self) -> ValidationOptions
Returns a copy 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 ValidationOptions
impl Debug for ValidationOptions
Source§impl Default for ValidationOptions
impl Default for ValidationOptions
Source§impl PartialEq for ValidationOptions
impl PartialEq for ValidationOptions
impl StructuralPartialEq for ValidationOptions
Auto Trait Implementations§
impl Freeze for ValidationOptions
impl RefUnwindSafe for ValidationOptions
impl Send for ValidationOptions
impl Sync for ValidationOptions
impl Unpin for ValidationOptions
impl UnwindSafe for ValidationOptions
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