Skip to main content

What is this?

django-session-csrf-cookie is Django middleware that provides a CSRF token cookie when using django-session-csrf. By design, django-session-csrf does not require a CSRF token cookie, but such a cookie is useful for AJAX requests and other web APIs, since it allows the client to get the CSRF token without parsing HTML. (Note that the cookie is not used by the server for any purpose, so the security hole django-session-csrf was designed to fix is still fixed.)

Installation

From PyPI:

pip install django-session-csrf-cookie

From github:

git clone git://github.com/trustcentric/django-session-csrf-cookie.git

Add session_csrf_cookie.CsrfCookieMiddleware to your MIDDLEWARE_CLASSES below session_csrf.CsrfMiddleware:

MIDDLEWARE_CLASSES = (
    ...
    'session_csrf.CsrfMiddleware',
    'session_csrf_cookie.CsrfCookieMiddleware',
    ...
)

Add session_csrf_cookie to INSTALLED_APPS.

Settings

session-csrf-cookie-middleware can be controlled using the following settings:

CSRF_COOKIE_NAME

The name used for the CSRF token cookie.

Default: csrftoken

CSRF_COOKIE_DOMAIN

The domain to be used when setting the CSRF cookie.

Default: None

CSRF_COOKIE_SECURE

Whether to use a secure cookie for the CSRF cookie.

Default: False

CSRF_COOKIE_HTTPONLY

Whether to set the HTTPOnly flag on the CSRF cookie.

Default: False

Metadata

Release files for django-session-csrf-cookie 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-session-csrf-cookie 0.1
File Size Uploaded Provenance Actions
django-session-csrf-cookie-0.1.tar.gz 3.7 kB Without provenance Details for django-session-csrf-cookie-0.1.tar.gz

Security for django-session-csrf-cookie 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page