pub struct MultiCsrfProtection { /* private fields */ }
Expand description
This is used when one wants to rotate keys or switch from implementation to another. It accepts
1 + N
instances of CsrfProtection
and uses only the first to generate tokens and cookies.
The N
remaining instances are used only for parsing.
Implementations§
Source§impl MultiCsrfProtection
impl MultiCsrfProtection
Sourcepub fn new(
current: Box<dyn CsrfProtection>,
previous: Vec<Box<dyn CsrfProtection>>,
) -> MultiCsrfProtection
pub fn new( current: Box<dyn CsrfProtection>, previous: Vec<Box<dyn CsrfProtection>>, ) -> MultiCsrfProtection
Create a new MultiCsrfProtection
from one current CsrfProtection
and some N
previous
instances of CsrfProtection
.
Trait Implementations§
Source§impl CsrfProtection for MultiCsrfProtection
impl CsrfProtection for MultiCsrfProtection
Given a nonce and a time to live (TTL), create a cookie to send to the end user.
Source§fn generate_token(&self, token_value: &[u8; 64]) -> Result<CsrfToken, CsrfError>
fn generate_token(&self, token_value: &[u8; 64]) -> Result<CsrfToken, CsrfError>
Given a nonce, create a token to send to the end user.
Given a decoded byte array, deserialize, decrypt, and verify the cookie.
Source§fn parse_token(&self, token: &[u8]) -> Result<UnencryptedCsrfToken, CsrfError>
fn parse_token(&self, token: &[u8]) -> Result<UnencryptedCsrfToken, CsrfError>
Given a decoded byte array, deserialize, decrypt, and verify the token.
Source§fn verify_token_pair(
&self,
token: &UnencryptedCsrfToken,
cookie: &UnencryptedCsrfCookie,
) -> bool
fn verify_token_pair( &self, token: &UnencryptedCsrfToken, cookie: &UnencryptedCsrfCookie, ) -> bool
Given a token pair that has been parsed, decoded, decrypted, and verified, return whether
or not the token matches the cookie and they have not expired.
Auto Trait Implementations§
impl Freeze for MultiCsrfProtection
impl !RefUnwindSafe for MultiCsrfProtection
impl Send for MultiCsrfProtection
impl Sync for MultiCsrfProtection
impl Unpin for MultiCsrfProtection
impl !UnwindSafe for MultiCsrfProtection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> PersistentInto<Arc<Mutex<T>>> for T
impl<T> PersistentInto<Arc<Mutex<T>>> for T
Source§fn persistent_into(self) -> Arc<Mutex<T>>
fn persistent_into(self) -> Arc<Mutex<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<RwLock<T>>> for T
impl<T> PersistentInto<Arc<RwLock<T>>> for T
Source§fn persistent_into(self) -> Arc<RwLock<T>>
fn persistent_into(self) -> Arc<RwLock<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<T>> for T
impl<T> PersistentInto<Arc<T>> for T
Source§fn persistent_into(self) -> Arc<T>
fn persistent_into(self) -> Arc<T>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<T> for T
impl<T> PersistentInto<T> for T
Source§fn persistent_into(self) -> T
fn persistent_into(self) -> T
Convert
self
into a value of type T
.