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