pub struct ChaCha20Poly1305CsrfProtection { /* private fields */ }
Expand description
Uses ChaCha20Poly1305 to provide signed, encrypted CSRF tokens and cookies.
Implementations§
Source§impl ChaCha20Poly1305CsrfProtection
impl ChaCha20Poly1305CsrfProtection
Sourcepub fn from_key(aead_key: [u8; 32]) -> ChaCha20Poly1305CsrfProtection
pub fn from_key(aead_key: [u8; 32]) -> ChaCha20Poly1305CsrfProtection
Given a key, return a ChaCha20Poly1305CsrfProtection
instance.
Trait Implementations§
Source§impl CsrfProtection for ChaCha20Poly1305CsrfProtection
impl CsrfProtection for ChaCha20Poly1305CsrfProtection
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 ChaCha20Poly1305CsrfProtection
impl RefUnwindSafe for ChaCha20Poly1305CsrfProtection
impl Send for ChaCha20Poly1305CsrfProtection
impl Sync for ChaCha20Poly1305CsrfProtection
impl Unpin for ChaCha20Poly1305CsrfProtection
impl UnwindSafe for ChaCha20Poly1305CsrfProtection
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
.