Trait rocket_csrf_guard::CsrfTokenVerifier
source · 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§
Required Methods§
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
impl CsrfTokenVerifier for DoubleSubmitCookieCsrfToken
Verifies that the received token matches the cookie.
type Proof = CsrfCheckProof
type Error = CsrfTokenVerificationError
source§impl<Proof, T> CsrfTokenVerifier for T
impl<Proof, T> CsrfTokenVerifier for T
Implements CsrfTokenVerifier
for any type implementing VerifierWithKnownExpectedToken