Skip to main content

Crate salvo_csrf

Crate salvo_csrf 

Source
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§

AesGcmCipheraes-gcm-cipher
CSRF protection implementation that uses AES-GCM.
BcryptCipherbcrypt-cipher
CSRF protection implementation that uses bcrypt.
CcpCipherccp-cipher
CcpCipher is a CSRF protection implementation that uses ChaCha20Poly1305.
CookieStorecookie-store
A CsrfStore implementation that stores the CSRF proof in a cookie.
Csrf
Cross-Site Request Forgery (CSRF) protection middleware.
FormFinder
Find token from request form body.
HeaderFinder
Find token from http request header.
HmacCipherhmac-cipher
A CSRF protection implementation that uses HMAC.
JsonFinder
Find token from request json body.
SessionStoresession-store
A CsrfStore implementation that stores the CSRF proof in a session.

Enums§

CsrfRotationPolicy
Controls when a CSRF token is rotated.

Constants§

CSRF_TOKEN_KEY
Key used to store the CSRF token in Depot.

Traits§

CsrfCipher
Generates and verifies CSRF token / proof pairs.
CsrfDepotExt
Extension for Depot.
CsrfStore
Storage backend for CSRF (token, proof) pairs.
CsrfTokenFinder
Used to find csrf token from request.

Functions§

aes_gcm_cookie_csrfaes-gcm-cipher and cookie-store
Helper function to create a Csrf use AesGcmCipher and CookieStore.
aes_gcm_csrfaes-gcm-cipher
Helper function to create a Csrf use AesGcmCipher.
aes_gcm_session_csrfaes-gcm-cipher and session-store
Helper function to create a Csrf use AesGcmCipher and SessionStore.
bcrypt_cookie_csrfbcrypt-cipher and cookie-store
Helper function to create a Csrf use BcryptCipher and CookieStore.
bcrypt_csrfbcrypt-cipher
Helper function to create a Csrf use BcryptCipher.
bcrypt_session_csrfbcrypt-cipher and session-store
Helper function to create a Csrf use BcryptCipher and SessionStore.
ccp_cookie_csrfccp-cipher and cookie-store
Helper function to create a Csrf use CcpCipher and CookieStore.
ccp_csrfccp-cipher
Helper function to create a Csrf use CcpCipher.
ccp_session_csrfccp-cipher and session-store
Helper function to create a Csrf use CcpCipher and SessionStore.
cookie_storecookie-store
Helper function to create a CookieStore.
hmac_cookie_csrfcookie-store and hmac-cipher
Helper function to create a Csrf use HmacCipher and CookieStore.
hmac_csrfhmac-cipher
Helper function to create a Csrf use HmacCipher.
hmac_session_csrfhmac-cipher and session-store
Helper function to create a Csrf use HmacCipher and SessionStore.
session_storesession-store
Helper function to create a SessionStore.