{ "info": { "author": "Jeff Balogh", "author_email": "jbalogh@mozilla.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Environment :: Web Environment :: Mozilla", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "What is this?\n-------------\n\n``django-session-csrf`` is an alternative implementation of Django's CSRF\nprotection that does not use cookies. Instead, it maintains the CSRF token on\nthe server using Django's session backend. The csrf token must still be\nincluded in all POST requests (either with `csrfmiddlewaretoken` in the form or\nwith the `X-CSRFTOKEN` header).\n\n\nInstallation\n------------\n\nFrom PyPI::\n\n pip install django-session-csrf\n\nFrom github::\n\n git clone git://github.com/mozilla/django-session-csrf.git\n\nReplace ``django.core.context_processors.csrf`` with\n``session_csrf.context_processor`` in your ``TEMPLATE_CONTEXT_PROCESSORS``::\n\n TEMPLATE_CONTEXT_PROCESSORS = (\n ...\n 'session_csrf.context_processor',\n ...\n )\n\nReplace ``django.middleware.csrf.CsrfViewMiddleware`` with\n``session_csrf.CsrfMiddleware`` in your ``MIDDLEWARE_CLASSES``\nand make sure it is listed after the AuthenticationMiddleware::\n\n MIDDLEWARE_CLASSES = (\n ...\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n ...\n 'session_csrf.CsrfMiddleware',\n ...\n )\n\nThen we have to monkeypatch Django to fix the ``@csrf_protect`` decorator::\n\n import session_csrf\n session_csrf.monkeypatch()\n\nMake sure that's in something like your root ``urls.py`` so the patch gets\napplied before your views are imported.\n\n\nDifferences from Django\n-----------------------\n\n``django-session-csrf`` does not assign CSRF tokens to anonymous users because\nwe don't want to support a session for every anonymous user. Instead, views\nthat need anonymous forms can be decorated with ``@anonymous_csrf``::\n\n from session_csrf import anonymous_csrf\n\n @anonymous_csrf\n def login(request):\n ...\n\n``anonymous_csrf`` uses the cache to give anonymous users a lightweight\nsession. It sends a cookie to uniquely identify the user and stores the CSRF\ntoken in the cache. It can be controlled through these settings:\n\n ``ANON_COOKIE``\n the name used for the anonymous user's cookie\n\n Default: ``anoncsrf``\n\n ``ANON_TIMEOUT``\n the cache timeout (in seconds) to use for the anonymous CSRF tokens\n\n Default: ``60 * 60 * 2 # 2 hours``\n\nNote that by default Django uses local-memory caching, which will not\nwork with anonymous CSRF if there is more than one web server thread.\nTo use anonymous CSRF, you must configure a cache that's shared\nbetween web server instances, such as Memcached. See the `Django cache\ndocumentation `_\nfor more information.\n\n\nIf you only want a view to have CSRF protection for logged-in users, you can\nuse the ``anonymous_csrf_exempt`` decorator. This could be useful if the\nanonymous view is protected through a CAPTCHA, for example.\n\n::\n\n from session_csrf import anonymous_csrf_exempt\n\n @anonymous_csrf_exempt\n def protected_in_another_way(request):\n ...\n\n\nIf you want all views to have CSRF protection for anonymous users, use\nthe following setting:\n\n ``ANON_ALWAYS``\n always provide CSRF protection for anonymous users\n\n Default: False\n\n\nWhy do I want this?\n-------------------\n\n1. Your site is on a subdomain with other sites that are not under your\n control, so cookies could come from anywhere.\n2. You're worried about attackers using Flash to forge HTTP headers.\n3. You're tired of requiring a Referer header.\n\n\nWhy don't I want this?\n----------------------\n\n1. Storing tokens in sessions means you have to hit your session store more\n often.\n2. It's a little bit more work to CSRF-protect forms for anonymous users.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mozilla/django-session-csrf", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-session-csrf", "package_url": "https://pypi.org/project/django-session-csrf/", "platform": "", "project_url": "https://pypi.org/project/django-session-csrf/", "project_urls": { "Homepage": "http://github.com/mozilla/django-session-csrf" }, "release_url": "https://pypi.org/project/django-session-csrf/0.7.1/", "requires_dist": null, "requires_python": "", "summary": "CSRF protection for Django without cookies.", "version": "0.7.1" }, "last_serial": 2381872, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d63ce7e278095ebe44c6abc4b548ffb8", "sha256": "0e0b6ee13c056ce3d4961e9d1de4391e67be4e334ea24f8e3dbab2d51fce4aec" }, "downloads": -1, "filename": "django-session-csrf-0.1.tar.gz", "has_sig": false, "md5_digest": "d63ce7e278095ebe44c6abc4b548ffb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5483, "upload_time": "2011-04-19T21:28:04", "url": "https://files.pythonhosted.org/packages/9c/23/decd7b61a77e2851512786be15edd5776a86ff26e7764ffc32359d9ffee8/django-session-csrf-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "0a4e58720ca23a30fcdeb5071d66d905", "sha256": "7325c1be5ff63ea8c0b7079a3b6f9fcb0436ecf7e493ceaeaf0f733118de6c6b" }, "downloads": -1, "filename": "django-session-csrf-0.2.tar.gz", "has_sig": false, "md5_digest": "0a4e58720ca23a30fcdeb5071d66d905", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6883, "upload_time": "2011-04-20T23:20:26", "url": "https://files.pythonhosted.org/packages/c4/09/86578e99298f321d419483485c9383898bd46b1afdaa60e860db22e0e97c/django-session-csrf-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "4f4f95465e762ded74fee3b68b7d07ba", "sha256": "5240e13a1b7d7c3fb94b517ad6d87091aa4820c382a3570a261d2a9d557e9c31" }, "downloads": -1, "filename": "django-session-csrf-0.3.tar.gz", "has_sig": false, "md5_digest": "4f4f95465e762ded74fee3b68b7d07ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6950, "upload_time": "2011-04-21T03:07:10", "url": "https://files.pythonhosted.org/packages/c8/54/573f3552cfaeee6d46bc9665e89436bfb15ceb71ca6a2d3923d2141e9538/django-session-csrf-0.3.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "f191999c363a152b183f6088eac93ab7", "sha256": "44e4639ec057a6b6a9dddb869d4e3a4818fc9278ec490cce39aef08440592a93" }, "downloads": -1, "filename": "django-session-csrf-0.5.tar.gz", "has_sig": false, "md5_digest": "f191999c363a152b183f6088eac93ab7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8061, "upload_time": "2012-01-27T20:43:12", "url": "https://files.pythonhosted.org/packages/6c/d5/24765375adfdb5685893b4190a49312e4f0f19128d408a67eee96ccd9a28/django-session-csrf-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "1cd692f7f297a030d86d3eac1c2aa126", "sha256": "ccfddfbf947a51c8b095a5e63bed43005a277a5581de92ed373eb06b75ceec77" }, "downloads": -1, "filename": "django_session_csrf-0.6-py2-none-any.whl", "has_sig": false, "md5_digest": "1cd692f7f297a030d86d3eac1c2aa126", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10643, "upload_time": "2016-01-15T13:34:14", "url": "https://files.pythonhosted.org/packages/43/d1/4617251e65144618cc98321a0a0c4f2ed551126813c1a5874ecbe9d2cd20/django_session_csrf-0.6-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f9b3b59f125bfdd722b8579640c5cdb4", "sha256": "009d574590aeebff230bda3d8c1cacd9d48b204cc1a784a5d3be3638727f8d16" }, "downloads": -1, "filename": "django-session-csrf-0.6.tar.gz", "has_sig": false, "md5_digest": "f9b3b59f125bfdd722b8579640c5cdb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8388, "upload_time": "2016-01-15T13:34:09", "url": "https://files.pythonhosted.org/packages/5d/69/88a119c9959a3b4aa5de52fc9534fbc34e89237c3ea558483e88f22d16b5/django-session-csrf-0.6.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "012605e818ee8ad7467fbd5b585bdc58", "sha256": "65791aca2c8c75b59c1e903e5bdd64d0e4fac7799367738ef96a0170ae2fd7e4" }, "downloads": -1, "filename": "django_session_csrf-0.7.0-py2-none-any.whl", "has_sig": false, "md5_digest": "012605e818ee8ad7467fbd5b585bdc58", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10669, "upload_time": "2016-09-30T20:28:38", "url": "https://files.pythonhosted.org/packages/41/0c/54cc5a64b57f8f10f41fb608ad643d65e34b20c49833cb508be38ef07c9f/django_session_csrf-0.7.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "553eb5d3abb093c55f1214d295c47cbe", "sha256": "98670d093c86e8f1e64a2197dda84c7aa1ff32acacb559e18c3104b56c4a0804" }, "downloads": -1, "filename": "django-session-csrf-0.7.0.tar.gz", "has_sig": false, "md5_digest": "553eb5d3abb093c55f1214d295c47cbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8375, "upload_time": "2016-09-30T20:28:36", "url": "https://files.pythonhosted.org/packages/db/fb/369ff4ed80723768ae0acfa09f67f5201f662dfe7ded8508b0bb2946a6ac/django-session-csrf-0.7.0.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "fc58f7403632e1b1cabcc2e09d1a19cc", "sha256": "ff8c10e30d312c77fc6a6db7710e22b9383e28c03b7fe958876ca96f39aa6cf2" }, "downloads": -1, "filename": "django_session_csrf-0.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fc58f7403632e1b1cabcc2e09d1a19cc", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10871, "upload_time": "2016-10-05T12:31:17", "url": "https://files.pythonhosted.org/packages/ea/45/4dea5e300c2349012ae3d49a930bf164fba7a9f1a3ef5d026c652ee3eb59/django_session_csrf-0.7.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8eeb5338fd4eb2e2d1813adcabfab511", "sha256": "e17177e6e2e6518ec7ce6693ad10a5c747f8571d09f4cfa9082599334421605d" }, "downloads": -1, "filename": "django-session-csrf-0.7.1.tar.gz", "has_sig": false, "md5_digest": "8eeb5338fd4eb2e2d1813adcabfab511", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8557, "upload_time": "2016-10-05T12:31:15", "url": "https://files.pythonhosted.org/packages/8b/dc/4bdbea0f023011d04851afdf271e0f7b1871efb04c18e1e6eea8cc7dc0f5/django-session-csrf-0.7.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fc58f7403632e1b1cabcc2e09d1a19cc", "sha256": "ff8c10e30d312c77fc6a6db7710e22b9383e28c03b7fe958876ca96f39aa6cf2" }, "downloads": -1, "filename": "django_session_csrf-0.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fc58f7403632e1b1cabcc2e09d1a19cc", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10871, "upload_time": "2016-10-05T12:31:17", "url": "https://files.pythonhosted.org/packages/ea/45/4dea5e300c2349012ae3d49a930bf164fba7a9f1a3ef5d026c652ee3eb59/django_session_csrf-0.7.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8eeb5338fd4eb2e2d1813adcabfab511", "sha256": "e17177e6e2e6518ec7ce6693ad10a5c747f8571d09f4cfa9082599334421605d" }, "downloads": -1, "filename": "django-session-csrf-0.7.1.tar.gz", "has_sig": false, "md5_digest": "8eeb5338fd4eb2e2d1813adcabfab511", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8557, "upload_time": "2016-10-05T12:31:15", "url": "https://files.pythonhosted.org/packages/8b/dc/4bdbea0f023011d04851afdf271e0f7b1871efb04c18e1e6eea8cc7dc0f5/django-session-csrf-0.7.1.tar.gz" } ] }