Skip to main content

A Django app to only allow access to certain pages based on IP addresses.

Project description

1 Welcome to django-ip-whitelist’s documentation!

Version:

0.1.7

Source:

https://github.com/maykinmedia/django-ip-whitelist

Keywords:

Django IP Whitelist, IP whitelist, pip package

PythonVersion:

3.9

Build status Code quality checks black Coverage status Documentation Status

python-versions django-versions pypi-version

This package provides a Django middleware that allows you to whitelist IP addresses that are allowed to access your site.

By default the user’s IP needs to conform to the IP whitelist in order to access the Django admin. You can either specify individual IP addresses or IP ranges, and the whitelist is manageable via the Django admin.

2 Installation

2.1 Requirements

  • Python 3.8 or above

  • setuptools 40.8.0 or above

  • Django 3.2 or newer

2.2 Install

pip install django-ip-whitelist

Add ip_whitelist to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'ip_whitelist',
    ...
]

3 Usage

Add the middleware to your MIDDLEWARE setting:

MIDDLEWARE = [
    ...
    'ip_whitelist.middleware.IPWhitelistMiddleware',
    ...
]

Add the IP addresses you want to whitelist to your settings.py:

WHITELIST_IPS = [
    ...
    '127.0.0.1',
    ...
]

Add the WHITELIST_IP_RANGES to your settings.py:

WHITELIST_IP_RANGES = [
    ...
    '
    ...
]

Add the OUTSIDE_IP_DISALLOWED_PATHS to your settings.py with disallowed URLs:

OUTSIDE_IP_DISALLOWED_PATHS = (
    ...
    '/admin',
    ...
)

3.1 Migrations

Run the migrations:

python manage.py migrate

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-ip-whitelist-0.1.7.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

django_ip_whitelist-0.1.7-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file django-ip-whitelist-0.1.7.tar.gz.

File metadata

  • Download URL: django-ip-whitelist-0.1.7.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for django-ip-whitelist-0.1.7.tar.gz
Algorithm Hash digest
SHA256 7229a9ac12eb14ac923d90f2b779c0cd0049cb52f1ea5568ed1f276039eb3efc
MD5 e90b12dc174af754a6f3ac2ee0644dd0
BLAKE2b-256 3272e847aa6c159853cdda6685a23323d691da31a6daf240c55b3698d1cd1564

See more details on using hashes here.

File details

Details for the file django_ip_whitelist-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ip_whitelist-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb89239c3a3fad2d8612c56425432466c0a427e4ae17f902ed78e14c19f4d13
MD5 7e32b96f1b936aae65aaca008ab76dfd
BLAKE2b-256 553bb89aa1db469e4c3556eb50c009af72c5d4e4ff30ae07c10bdee5105af46d

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