{ "info": { "author": "Philip Mateescu", "author_email": "dev@philipm.at", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": "Permissive CSRF for Django\n==========================\n\nAre you using Django and trying to POST from a normal HTTP page \nto an HTTPS, only to be hit by the puzzling \n*\"Referer checking failed - http://example.com/ does not match https://example.com/\"*?\n\nFirst, you should know that there are `good reasons why this is happening`_,\nand in understanding them you can decide whether trading off security \nfor convenience is worth it.\n\nSecond, the best way to solve this issue is to \nuse HTTPS on all your pages and with packages like `django-sslify`_\nyou have no excuse not to.\n\nIf, after reading all the above, you're still set on making the trade,\nhere is how to use PermissiveCSRF in your Django site.\n\n\nInstallation\n------------\n\nInstall from PyPi::\n \n pip install django-permissivecsrf\n\n.. Or install the version currently in development using pip\n pip install -e git+git://github.com/philipmat/django-permissivecsrf/tarball/master#egg=django-permissivecsrf-dev\n\n\nUsage\n-----\n\nModify your Django ``settings.py`` file and add ``permissivecsrf`` to \nthe list of installed applications::\n\n INSTALLED_APPS = (\n # ...\n 'permissivecsrf',\n )\n\n\n*Prepend* PermissiveCSRF to your ``MIDDLEWARE_CLASSES``::\n\n MIDDLEWARE_CLASSES = (\n 'permissivecsrf.middleware.PermissiveCSRFMiddleware',\n # ...\n )\n\n**Note:** PermissiveCSRF works with `django-sslify`_ too. Although the order doesn't really matter,\nyou probably want PermissiveCSRF after the django-sslify inclusion::\n\n\n MIDDLEWARE_CLASSES = (\n 'sslify.middleware.SSLifyMiddleware',\n 'permissivecsrf.middleware.PermissiveCSRFMiddleware',\n # ...\n )\n\n\nHow does it work?\n-----------------\n\nThe `Django CSRF middleware`_ performs an extra-check if the request is over HTTPS to \nensure that the request came from the same site, i.e. that \nthe referrer (HTTP-Referer header) matches the current site.\n\nIn other words, in ensures that the call to https://example.com/account/login\ncame from another page of https://example.com/. As such, if you put your login \nform on your non-secure homepage, http://example.com/, but use a secure target \nfor your form's *action* attribute, ``