Structs§
Enums§
- Csrf
Pattern CsrfPattern
allows use to configureCsrfMiddleware
to read and store csrf tokens and user sessions in client’s browser cookie or in any persistent storage like Redis, Postgres or in-memory that implementsactix_session::storage::SessionStore
trait if you have enabledsession
feature.- Csrf
Token Validator - Token
Class
Constants§
- CSRF_
PRE_ SESSION_ KEY - Cookie name of pre-session generated by
CsrfMiddleware
for allowed unauthorized routes that need to mutate data when there’s not authorized user yet. For example in cases such as registration, login or newsletter subscription. - DEFAULT_
CSRF_ ANON_ TOKEN_ KEY - Cookie name used to store the anonymous (pre-session) token
- DEFAULT_
CSRF_ TOKEN_ FIELD - Csrf token field name in
application/x-www-form-urlencoded
orapplication/json
body.CsrfMiddleware
will try to extract a token from that field. - DEFAULT_
CSRF_ TOKEN_ HEADER - DEFAULT_
CSRF_ TOKEN_ KEY - Cookie name or actix-session key used to store the authorized (session-bound) token
- DEFAULT_
SESSION_ ID_ KEY - Key of user session created outside the middleware. It’s cookie name or actix-session key
depending on enabled
session
feature and middleware core will extract value by this key to use this unique session id in HMAC hashes. That’s howCsrfMiddleware
can be integrated into existing applications that already have authorization logic.
Traits§
- Csrf
Request Ext - Extension trait for Actix HttpRequest to rotate CSRF token without passing the config explicitly.
Functions§
- eq_
tokens - generate_
hmac_ token_ ctx - generate_
random_ token - rotate_
csrf_ token_ in_ response - validate_
hmac_ token - Test util: validates an authorized token
- validate_
hmac_ token_ ctx