cedarling

Struct TokenValidationConfig

source
pub struct TokenValidationConfig {
    pub iss_validation: bool,
    pub aud_validation: bool,
    pub sub_validation: bool,
    pub jti_validation: bool,
    pub iat_validation: bool,
    pub exp_validation: bool,
    pub nbf_validation: bool,
}
Expand description

Validation options related to JSON Web Tokens (JWT).

This struct provides the configuration for validating common JWT claims (iss, aud, sub, jti, exp, nbf) across different types of JWTs.

The default configuration for Access Tokens, ID Tokens, and Userinfo Tokens can be easily instantiated via the provided methods.

Fields§

§iss_validation: bool

Requires the iss claim to be present in the JWT and the scheme must be https.

§aud_validation: bool

Requires the aud claim to be present in the JWT.

§sub_validation: bool

Requires the sub claim to be present in the JWT.

§jti_validation: bool

Requires the jti claim to be present in the JWT.

§iat_validation: bool

Requires the iat claim to be present in the JWT.

§exp_validation: bool

Requires the exp claim to be present in the JWT and the current timestamp isn’t past the specified timestamp in the token.

§nbf_validation: bool

Requires the nbf claim to be present in the JWT.

Implementations§

source§

impl TokenValidationConfig

source

pub fn required_claims(&self) -> HashSet<Box<str>>

Collects all the required claims into a HashSet.

source

pub fn access_token() -> Self

Returns a default configuration for validating Access Tokens.

This configuration requires the following:

  • iss (Issuer)
  • jti (JWT ID)
  • exp (Expiration)
source

pub fn id_token() -> Self

Returns a default configuration for validating ID Tokens.

This configuration requires the following:

  • iss (Issuer)
  • aud (Audience)
  • sub (Subject)
  • exp (Expiration)
source

pub fn userinfo_token() -> Self

Returns a default configuration for validating Userinfo Tokens.

This configuration requires the following:

  • iss (issuer)
  • aud (audience)
  • sub (subject)
  • exp (expiration)

Trait Implementations§

source§

impl Debug for TokenValidationConfig

source§

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

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

impl Default for TokenValidationConfig

source§

fn default() -> TokenValidationConfig

Returns the “default value” for a type. Read more
source§

impl PartialEq for TokenValidationConfig

source§

fn eq(&self, other: &TokenValidationConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for TokenValidationConfig

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

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

source§

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>,

source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T