Simple middleware for filtering requests by their source IP address
Project description
Simple middleware for blocking requests by IP Address
Quickstart
Install Django Middlewall:
pip install django-middlewall
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'middlewall.apps.MiddlewallConfig',
...
)
Enable middleware components:
# enable both white and black listing
MIDDLEWARE = [
'middlewall.middleware.BlacklistMiddleware',
'middlewall.middleware.WhitelistMiddleware',
...
]
Define access lists in CIDR notation:
# only allow requests from these subnets
MIDDLEWALL_WHITELIST = ['192.0.2.0/24', '198.51.100.0/24']
# also block this specific address
MIDDLEWALL_BLACKLIST = ['192.0.2.1/32']
(optional) Define a custom function to get remote addresses from request objects:
# take advantage of the X_FORWARDED_FOR support in ipware
MIDDLEWALL_ADDRESS_GETTER = 'ipware.ip.get_ip'
Running Tests
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -e .[test] (myenv) $ pip install tox (myenv) $ tox
Credits
History
0.1.1 (2017-03-09)
First release.
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-middlewall-0.1.1.tar.gz
.
File metadata
- Download URL: django-middlewall-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3bcb4f4e56cd65cc9be3ab14e9b0106a62a3b640d223309e119cc6547b9f57e |
|
MD5 | 50e4adf7b2bbe3c40a65155cda784019 |
|
BLAKE2b-256 | ea72c663e52050aed3d51e0996d13eaa2f5f0c713e25f7f265ee5d4e3248b968 |
Provenance
File details
Details for the file django_middlewall-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_middlewall-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbeede1c5dfa60431558705d5518188709c5e5d62607b531b0e945720837e80d |
|
MD5 | 955ce2f2924deb91d3ab7a6ac4655d8e |
|
BLAKE2b-256 | 35a3733794bbf3793f4a956cf672eb40f2542c4bc4b3ca6df46fa7531c11e40f |