Skip to main content

Apply an IP restriction to specific routes

Project description

django-simple-ip-restrict

This middleware allows you to mark Django URL namespaces as unavailable to all requests except those coming from a whitelisted IP subnet.

Instructions

Add to the list of MIDDLEWARE:

"django_simple_ip_restrict.middleware.ip_filter",

Then you can set the following keys on settings.py:

  • IP_PROTECTED_NAMESPACES: list of namespaces to block (default: ["admin"])
  • IP_NETWORKS_WHITELIST: list of subnets to allow, in CIDR notation

Manual deployment

Since we don't have a CI/CD pipeline set up right now. You'll have to follow the following steps to release

  1. Do your changes
  2. Install bumpversion and twine
pip install twine bumpversion
  1. Bump the version using bumpversion
bumpversion patch
  1. A commit should be made automatically, just push
git push
  1. Build using setup.py
python setup.py sdist
  1. Push to pypi using twine
twine upload dist/*

Use 1password to find the credentials for pypi.

In order to upload, we have 2FA and the following needs to be done:

  • username should be "__token__"
  • password should be the Access Token value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_simple_ip_restrict-1.0.46.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file django_simple_ip_restrict-1.0.46.tar.gz.

File metadata

File hashes

Hashes for django_simple_ip_restrict-1.0.46.tar.gz
Algorithm Hash digest
SHA256 e0f70f7e548071776186b41bf65ea335cbfd29a63dd02c35f1c3db1d8f181a5a
MD5 da195e81a74afeec1ab7440026e7e528
BLAKE2b-256 aa1029e38db3bd5179254bd603640702e98b86e86672cc8ebb7591321eba8591

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page