Skip to main content

django-http-referrer-policy provides a middleware class implementing the Referrer-Policy header for Django-powered sites.

Project description

https://badge.fury.io/py/django-http-referrer-policy.svg https://travis-ci.org/DmytroLitvinov/django-http-referrer-policy.svg?branch=master Documentation Status https://codecov.io/gh/DmytroLitvinov/django-http-referrer-policy/branch/master/graph/badge.svg

django-referrer-policy provides a middleware class implementing the Referrer-Policy header for Django-powered sites.

Note: Starting from Django v3.0, Django itself has default support

of Referrer-Policy header in SecurityMiddleware via setting variable SECURE_REFERRER_POLICY.

Documentation

The full documentation is at https://django-http-referrer-policy.readthedocs.io.

Quickstart

Install Django HTTP Referrer Policy:

pip install django-http-referrer-policy

Add Django HTTP Referrer Policy Middleware to your settings:

MIDDLEWARE = [
    ...
    'django_http_referrer_policy.middleware.ReferrerPolicyMiddleware',
    ...
]

Optional: provide variable REFERRER_POLICY to your settings with valid value if default value 'no-referrer-when-downgrade' does not suit to you:

REFERRER_POLICY = 'no-referrer'

More details about valid referrer policies: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy#Syntax

Running Tests

Does the code actually work?

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

Credits

Maintainable version of original library.

Tools used in rendering this package:

History

1.1.1 (2020-11-02)

  • Add deprecation warning about Django v3.0. Django itself has default support of Referrer-Policy header in SecurityMiddleware via setting variable SECURE_REFERRER_POLICY.

1.1.0 (2020-10-27)

  • Set default value to 'no-referrer-when-downgrade' instead of requiring it

  • Add Django 3.1 and Python 3.9 for testing

1.0.1 (2019-08-23)

  • Update setup.py

  • Update docs for setting value in django-settings.

1.0.0 (2019-08-11)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-http-referrer-policy-1.1.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

django_http_referrer_policy-1.1.1-py2.py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page