Skip to main content

JwtConfig

Struct JwtConfig 

Source
pub struct JwtConfig {
    pub jwks: Option<String>,
    pub jwt_sig_validation: bool,
    pub jwt_status_validation: bool,
    pub signature_algorithms_supported: HashSet<Algorithm>,
    pub token_cache_max_ttl_secs: usize,
    pub token_cache_capacity: usize,
    pub token_cache_earliest_expiration_eviction: bool,
    pub trusted_issuer_loader: TrustedIssuerLoaderConfig,
    pub jwks_refresh_interval: Option<u64>,
    pub jwks_refresh_min_interval: u64,
    pub status_list_refresh_interval_max: u64,
}
Expand description

The set of Bootstrap properties related to JWT validation.

Fields§

§jwks: Option<String>

A Json Web Key Store (JWKS) with public keys.

If this is used, Cedarling will no longer try to fetch JWK Stores from a trustede identity provider and stick to using the local JWKS.

§jwt_sig_validation: bool

Check the signature for all the Json Web Tokens.

This Requires the iss claim to be present in all the tokens and and the scheme must be https.

This setting overrides the iss validation settings in the following:

  • access_token_config
  • id_token_config
  • userinfo_token_config
§jwt_status_validation: bool

Whether to check the status of the JWT.

On startup, the Cedarling will fetch and retreive the latest Status List JWT from the .well-known/openid-configuration via the status_list_endpoint claim and cache it.

See the IETF Draft for more info.

§signature_algorithms_supported: HashSet<Algorithm>

Only tokens signed with algorithms in this list can be valid.

§token_cache_max_ttl_secs: usize

Maximum TTL (in seconds) for cached tokens. Zero disables the token cache entirely.

Defaults to Self::DEFAULT_TOKEN_CACHE_MAX_TTL_SECS (5 seconds): small enough that revocation / status-list changes are picked up promptly while still serving repeated requests for the same token from cache. Keep this value short (seconds, not minutes) to bound cache growth and staleness.

§token_cache_capacity: usize

Maximum number of tokens the cache can store.

§token_cache_earliest_expiration_eviction: bool

Enables eviction policy based on the earliest expiration time.

When the cache reaches its capacity, the entry with the nearest expiration timestamp will be removed to make room for a new one.

§trusted_issuer_loader: TrustedIssuerLoaderConfig

Configuration for loading trusted issuers.

§jwks_refresh_interval: Option<u64>

Optional override for JWKS periodic refresh interval in seconds. Set to None to use the server-driven or fallback interval.

§jwks_refresh_min_interval: u64

Minimum interval in seconds between on-demand JWKS re-fetches per issuer.

§status_list_refresh_interval_max: u64

Upper bound on the Status List JWT refresh interval in seconds.

Caps how long Cedarling waits between Status List refreshes. When the Status List JWT carries a ttl claim (per the IETF oauth-status-list spec), the effective refresh interval is min(jwt_ttl, status_list_refresh_interval_max) so the issuer can always request a more frequent refresh, but never a less frequent one. When the JWT omits ttl, this value is used directly.

A value of 0 is treated as “use the default” so the cache cannot be left to go stale forever. Non-zero values below MIN_STATUS_LIST_REFRESH_SECS (5) are clamped to that minimum.

Implementations§

Source§

impl JwtConfig

Source

pub const DEFAULT_TOKEN_CACHE_CAPACITY: usize = 100

Default maximum number of tokens the token cache can store.

Source

pub const DEFAULT_TOKEN_CACHE_MAX_TTL_SECS: usize = 5

Default maximum TTL (seconds) for cached tokens.

Chosen as a small value so that repeated requests for the same token are served from cache, while revocation / status-list changes are still picked up within a few seconds. Prevents unbounded cache growth for tokens without an exp claim.

Source

pub const DEFAULT_JWKS_REFRESH_MIN_INTERVAL: u64 = 30

Default minimum interval (seconds) between on-demand JWKS re-fetches per issuer.

Source

pub const DEFAULT_STATUS_LIST_REFRESH_INTERVAL_MAX_SECS: u64 = 300

Default upper bound for the Status List JWT refresh interval (in seconds), applied when the Status List JWT has no ttl claim and as a cap on JWT- provided values. Also used when the bootstrap property is set to 0.

Source

pub fn new_without_validation() -> Self

Creates a new JwtConfig instance with validation turned off for all tokens.

Intended for tests and trusted-environment embedders. Production deployments should use JwtConfig::default (strict).

Source

pub fn allow_all_algorithms(self) -> Self

Adds all supported algorithms to signature_algorithms_supported.

Trait Implementations§

Source§

impl Clone for JwtConfig

Source§

fn clone(&self) -> JwtConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for JwtConfig

Source§

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

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

impl Default for JwtConfig

Source§

fn default() -> Self

Cedarling uses strict-by-default validation.

The returned value is identical to what is produced when parsing an empty bootstrap configuration (BootstrapConfigRaw::default()JwtConfig). Signature and status validation are on. To opt out for testing or trusted environments, set the flags explicitly or use JwtConfig::new_without_validation.

Source§

impl<'de> Deserialize<'de> for JwtConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for JwtConfig

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for JwtConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JwtConfig

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

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

Source§

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

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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