django-csrf-protect-form
The CSRF middleware and template tag from Django framework provides easy-to-use protection against Cross Site Request Forgeries. This protector has some inconveniences for XHR POST requests.
This module enables CSRF protection only for HTML forms when content type of the request is one of the following:
application/x-www-form-urlencoded
multipart/form-data
text/plain
It is generally safe to exclude XHR requests from CSRF protection, because XHR requests can only be made from the same origin. Check your CORS configuration before using this module. Use django-cors-headers module to protect your site with CORS.
Installation
Install with pip or pipenv:
pip install django-csrf-protect-form
Configuration
You can set a list of content types which have CSRF protection enabled. The default value is:
CSRF_PROTECT_FORM_CONTENT_TYPE = [
'application/x-www-form-urlencoded',
'multipart/form-data',
'text/plain',
]
Usage
views.py
from django_csrf_protect_form import csrf_protect_form
@csrf_protect_form
def hello(request):
return HttpResponse("<html><head></head><body>Hello, world!</body></html>")
or:
urls.py
from django_csrf_protect_form import csrf_protect_form
from .views import hello
urlpatterns = [
url('hello/', csrf_protect_form(hello)),
]
Documentation
License
Copyright © 2019, Piotr Roszatycki
This software is distributed under the GNU Lesser General Public License (LGPL 3 or greater).
Metadata
Release files for django-csrf-protect-form 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-csrf-protect-form-0.1.0.tar.gz | 16.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_csrf_protect_form-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 22.8 kB
Release files / django-csrf-protect-form-0.1.0.tar.gz
| Download URL | django-csrf-protect-form-0.1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49eef8a290a6bf1a66db3d49baeb792cb04ddc52ad5e7600f9ed40cebdbb2a8d
|
|
BLAKE2b-256 checksum How to use checksums |
6b31735050f43c2dedb1623844cc9636ed9eeb0a828d9d54a5a756a378c36464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.3
|
Release files / django_csrf_protect_form-0.1.0-py2.py3-none-any.whl
| Download URL | django_csrf_protect_form-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
336e21f048b4e50423968c671faa55cb087d3a607b2943aa36710d9fa3c99151
|
|
BLAKE2b-256 checksum How to use checksums |
5f58342080ae544b33d529ec3b7e783c7e9b9bcff31e810b664945bcc591b9c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.3
|
Security for django-csrf-protect-form 0.1.0
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.