ASGI middleware for protecting against CSRF attacks. Current version 0.11. Release cadence is irregular, last release 2023-02-06.
pip install asgi-csrfVerified import paths — ran on the pinned version, not inferred.
Wrap any ASGI app with CSRF protection. Secret must be set.
Update to 0.11 and ensure build tooling supports PEP 621.
Add always_set_cookie=True to middleware initialization.
Do not rely on CSRF protection for Bearer token endpoints.
Use send_csrf_failed callback instead of custom exception handling.