Expand description
CSRF middleware for Salvo web framework.
CSRF middleware for Salvo that provides CSRF (Cross-Site Request Forgery) protection.
CSRF token systems commonly use one of two rotation strategies:
CsrfRotationPolicy::PerSession: reuse the same token until it expires or disappears from the configured store. This is the default because it works well with page refreshes, browser back or forward navigation, and multiple tabs.CsrfRotationPolicy::PerRequest: rotate the token after every accepted request. This shortens the lifetime of each token, but clients must always submit the latest token from the most recent response.
Rotation policy is independent from storage. Tokens can be saved in cookies via
CookieStore or in session via
SessionStore. SessionStore need to
work with salvo-session crate.
Use Csrf::rotation_policy to opt into request-level rotation when needed.
Read more: https://salvo.rs
Structs§
- AesGcm
Cipher aes-gcm-cipher - CSRF protection implementation that uses AES-GCM.
- Bcrypt
Cipher bcrypt-cipher - CSRF protection implementation that uses bcrypt.
- CcpCipher
ccp-cipher - CcpCipher is a CSRF protection implementation that uses
ChaCha20Poly1305. - Cookie
Store cookie-store - A
CsrfStoreimplementation that stores the CSRF proof in a cookie. - Csrf
- Cross-Site Request Forgery (CSRF) protection middleware.
- Form
Finder - Find token from request form body.
- Header
Finder - Find token from http request header.
- Hmac
Cipher hmac-cipher - A CSRF protection implementation that uses HMAC.
- Json
Finder - Find token from request json body.
- Session
Store session-store - A
CsrfStoreimplementation that stores the CSRF proof in a session.
Enums§
- Csrf
Rotation Policy - Controls when a CSRF token is rotated.
Constants§
- CSRF_
TOKEN_ KEY - Key used to store the CSRF token in
Depot.
Traits§
- Csrf
Cipher - Generates and verifies CSRF token / proof pairs.
- Csrf
Depot Ext - Extension for Depot.
- Csrf
Store - Storage backend for CSRF
(token, proof)pairs. - Csrf
Token Finder - Used to find csrf token from request.
Functions§
- aes_
gcm_ cookie_ csrf aes-gcm-cipherandcookie-store - Helper function to create a
CsrfuseAesGcmCipherandCookieStore. - aes_
gcm_ csrf aes-gcm-cipher - Helper function to create a
CsrfuseAesGcmCipher. - aes_
gcm_ session_ csrf aes-gcm-cipherandsession-store - Helper function to create a
CsrfuseAesGcmCipherandSessionStore. - bcrypt_
cookie_ csrf bcrypt-cipherandcookie-store - Helper function to create a
CsrfuseBcryptCipherandCookieStore. - bcrypt_
csrf bcrypt-cipher - Helper function to create a
CsrfuseBcryptCipher. - bcrypt_
session_ csrf bcrypt-cipherandsession-store - Helper function to create a
CsrfuseBcryptCipherandSessionStore. - ccp_
cookie_ csrf ccp-cipherandcookie-store - Helper function to create a
CsrfuseCcpCipherandCookieStore. - ccp_
csrf ccp-cipher - Helper function to create a
CsrfuseCcpCipher. - ccp_
session_ csrf ccp-cipherandsession-store - Helper function to create a
CsrfuseCcpCipherandSessionStore. - cookie_
store cookie-store - Helper function to create a
CookieStore. - hmac_
cookie_ csrf cookie-storeandhmac-cipher - Helper function to create a
CsrfuseHmacCipherandCookieStore. - hmac_
csrf hmac-cipher - Helper function to create a
CsrfuseHmacCipher. - hmac_
session_ csrf hmac-cipherandsession-store - Helper function to create a
CsrfuseHmacCipherandSessionStore. - session_
store session-store - Helper function to create a
SessionStore.