Struct aliri::jwt::CoreValidator

source ·
pub struct CoreValidator { /* private fields */ }
Expand description

A core validator for JWTs

A default validator configured with common expected validations.

Implementations§

source§

impl CoreValidator

source

pub fn with_leeway(self, leeway: Duration) -> Self

Allows a grace period for token validation

Applies on either side of the “not before” and “expires” claims.

source

pub fn with_leeway_secs(self, leeway: u64) -> Self

Allows a grace period (in seconds) for token validation

Applies on either side of the “not before” and “expires” claims.

source

pub fn check_expiration(self) -> Self

Enforces expiration checks

source

pub fn check_not_before(self) -> Self

Enforces “not valid before” checks

source

pub fn ignore_expiration(self) -> Self

Skips expiration checks

source

pub fn ignore_not_before(self) -> Self

Skips “not valid before” checks

source

pub fn add_allowed_audience(self, audience: Audience) -> Self

Adds a single audience to the set of allowed audiences

source

pub fn extend_allowed_audiences<I: IntoIterator<Item = Audience>>( self, alg: I ) -> Self

Adds multiple audiences to the set of allowed audiences

source

pub fn add_approved_algorithm(self, alg: Algorithm) -> Self

Approves a single algorithm

source

pub fn extend_approved_algorithms<I: IntoIterator<Item = Algorithm>>( self, alg: I ) -> Self

Approves multiple algorithms

source

pub fn require_issuer(self, issuer: Issuer) -> Self

Require that tokens specify a particular issuer

source

pub fn check_subject(self, sub_regex: Regex) -> Self

Require that the sub claim exists and matches a particular regular expression

Trait Implementations§

source§

impl Clone for CoreValidator

source§

fn clone(&self) -> CoreValidator

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CoreValidator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CoreValidator

source§

fn default() -> Self

The default validator does not accept any algorithms and that the token is not expired (no grace period)

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.