Skip to main content

django-cookies-samesite

https://badge.fury.io/py/django-cookies-samesite.svg https://travis-ci.org/jotes/django-cookies-samesite.svg?branch=master https://codecov.io/gh/jotes/django-cookies-samesite/branch/master/graph/badge.svg

Django 2.1.x introduces support of SameSite flag for session and csrf cookie.

Unfortunately, this functionality will not be ported to older versions of Django e.g. 1.11.x.

This repository contains a middleware which automatically sets SameSite attribute for session and csrf cookies in legacy versions of Django.

Quickstart

Install django-cookies-samesite:

pip install django-cookies-samesite

Add the middleware to the top of MIDDLEWARE_CLASSES:

MIDDLEWARE_CLASSES = (
    'django_cookies_samesite.middleware.CookiesSameSite',
    ...
)

Set your preferred SameSite policy in settings.py:

SESSION_COOKIE_SAMESITE = 'Lax'

This can be ‘Lax’, ‘Strict’, or None to disable the flag.

Also, you can set this flag in your custom cookies:

SESSION_COOKIE_SAMESITE_KEYS = {'my-custom-cookies'}

After that you should be able to see SameSite flag set for session and csrf cookies: ![screenshot]()

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

History

0.1.0 (2018-05-16)

  • First release on PyPI.

Metadata

Release files for django-cookies-samesite-fork 0.2.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-cookies-samesite-fork 0.2.1
File Size Uploaded Provenance Actions
django-cookies-samesite-fork-0.2.1.tar.gz 5.2 kB Without provenance Details for django-cookies-samesite-fork-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-cookies-samesite-fork 0.2.1
File Interpreter ABI Platform Actions
django_cookies_samesite_fork-0.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for django_cookies_samesite_fork-0.2.1-py2.py3-none-any.whl

Total release size: 10.2 kB

Release files / django-cookies-samesite-fork-0.2.1.tar.gz

Download URL django-cookies-samesite-fork-0.2.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7d064b2fd1e0b5aa3037a35c7907c9bccc5384f8899dc02412b947820e0acb59
BLAKE2b-256 checksum
How to use checksums
bbdc2c72529dbca6610d11b7a5146d0b49c26edb347b9864f1e81d7999b4d6d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4

Release files / django_cookies_samesite_fork-0.2.1-py2.py3-none-any.whl

Download URL django_cookies_samesite_fork-0.2.1-py2.py3-none-any.whl
Size 5.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
053540e7dad735423afb6307e7c23287072b517eb848a520251d7bfd1aace150
BLAKE2b-256 checksum
How to use checksums
be86fec6096e064ca24a7d17f3ae71dd6e280fdda8e512e751d7ef9f77ce294e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4

Security for django-cookies-samesite-fork 0.2.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.2.1 This release

2 release files 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