A Django Middleware to enalbe use of CIDR IP ranges in ALLOWED_HOSTS.
Project description
A Django Middleware to enalbe use of CIDR IP ranges in ALLOWED_HOSTS.
Documentation
The full documentation is at https://django-allow-cidr.readthedocs.io.
Quickstart
Install Django Allow CIDR:
pip install django-allow-cidr
Add the Middleware to your MIDDLEWARE_CLASSES (for Django < 1.10) or MIDDLEWARE settings. It should be the first in the list:
MIDDLEWARE = (
'allow_cidr.middleware.AllowCIDRMiddleware',
...
)
Add the ALLOW_CIDR_NETS setting:
ALLOW_CIDR_NETS = ['192.168.1.0/24']
Profit!
Features
The normal ALLOWED_HOSTS values will also work as intended. This Middleware is intended to augment, not replace, the normal Django function.
If you do define ALLOW_CIDR_NETS and it has values, the middleware will capture what you have in ALLOWED_HOSTS, set ALLOWED_HOSTS to [‘*’] and take over validation of host headers.
The ALLOW_CIDR_NETS values can be any valid network definition for the netaddr package.
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-02-16)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-allow-cidr-0.1.0.tar.gz
.
File metadata
- Download URL: django-allow-cidr-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94b436b7ebf0bba9c1c4bddc28ada13aa86baa692c5c10c3012837bb8cf44a07 |
|
MD5 | 946a04dd81824c1bb235c302ffa8108c |
|
BLAKE2b-256 | 917aff375fd6dfd69e7e7624af85fef76b9bacb3c9ef6424239042eacb57ed60 |
File details
Details for the file django_allow_cidr-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_allow_cidr-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4e6f28109aebf06645e0218212acb2ba4ac6e98ee370fe9da0a90a4c0cf2b0 |
|
MD5 | e179d80da918cb138e65d029211fb41e |
|
BLAKE2b-256 | 103c2d0f5e423e22531f50a47053ea84abea48da06c0123923330d1617dcfd45 |