Skip to main content

ReplayStore

Trait ReplayStore 

Source
pub trait ReplayStore:
    Send
    + Sync
    + 'static {
    // Required method
    fn put_if_absent<'life0, 'life1, 'async_trait>(
        &'life0 self,
        jti: &'life1 str,
        ttl: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<bool, ReplayError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Atomic single-use marker store, keyed by jti.

A real deployment should back this with something shared across every verifier instance in the trust domain (e.g. Redis with SET key val NX PX ttl) — if several verifiers each keep an independent local cache, a request replayed to a different verifier instance succeeds. See the crate-level docs for the “replay scope” requirement this trait exists to satisfy.

Required Methods§

Source

fn put_if_absent<'life0, 'life1, 'async_trait>( &'life0 self, jti: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, ReplayError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically records jti if and only if it is not already present.

Returns Ok(true) if jti was newly inserted (request may proceed), Ok(false) if it was already present (replay — reject). Err means the store itself failed; the caller must treat this identically to Ok(false) (fail closed, never fail open).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§