pub trait CsrfTokenVerifier {
    type Proof: Send + Sync + 'static;
    type Error: Send + Sync;

    // Required method
    fn verify<'life0, 'life1, 'async_trait>(
        &'life0 self,
        token: &'life1 (dyn WithUserProvidedCsrfToken + Send + Sync)
    ) -> Pin<Box<dyn Future<Output = Result<Self::Proof, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A type that can verify whether a WithUserProvidedCsrfToken actually has a valid csrf token Lets us be generic over session based or other csrf tokens This trait is async, but we recommend you keep DB fetches out (use rocket request caching as in the examples) or other mechanisms to keep things quick The returned Proof will be set in the request local cache for other request guards to query

Required Associated Types§

source

type Proof: Send + Sync + 'static

source

type Error: Send + Sync

Required Methods§

source

fn verify<'life0, 'life1, 'async_trait>( &'life0 self, token: &'life1 (dyn WithUserProvidedCsrfToken + Send + Sync) ) -> Pin<Box<dyn Future<Output = Result<Self::Proof, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

source§

impl CsrfTokenVerifier for DoubleSubmitCookieCsrfToken

Verifies that the received token matches the cookie.

source§

impl<Proof, T> CsrfTokenVerifier for T
where Proof: Default + Send + Sync + 'static, T: VerifierWithKnownExpectedToken<Proof = Proof> + Send + Sync + 'static,

Implements CsrfTokenVerifier for any type implementing VerifierWithKnownExpectedToken