Skip to main content

django-ip-access

Python 3.11 Django 5.2 Python CI codecov Code style: black security: bandit

Access a Django app with authorized IP address

Installation

Install with pip

pip install django-ip-access

Setup

In order to make django-ip-access works, you'll need to follow the steps below.

Settings

First you need to add the following to your setings:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',

    'django_ip_access',
    ...
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    
    'django_ip_access.middleware.IpAccessMiddleware',
    ...
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    
    'django_ip_access.backends.IpAccessBackend',
    ...
)

The settings with their default values:

IP_ACCESS_URLS_WHITELIST = [] # list of path or absolute urls where the IP authentication will take place. I.e. ["/", "https://www.example.com/hello/"]

Migrations

Next, you need to run the migrations in order to update your database schema.

python manage.py migrate

How to use ?

Once you are all set up, when a request to your app is made, the IpAccessMiddleware checks for if the IP address of the request exists in the admin panel and if the user associated to the IP address is active.

Tests

Testing is managed by pytest. required packages for testing can be installed with:

make install

Metadata

Release files for django-ip-access 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ip-access 3.0.2
File Size Uploaded
django_ip_access-3.0.2.tar.gz 20.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-ip-access 3.0.2
File Interpreter ABI Platform
django_ip_access-3.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 40.7 kB

Release files / django_ip_access-3.0.2.tar.gz

Download URL django_ip_access-3.0.2.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2d1b08b5b6b21bb24a7b9639f9ed7c1c7a3c64a894cfc78175bc86e590d888ac
BLAKE2b-256 checksum
How to use checksums
6bd6ddf82d88aae00fe79e104a6a5f2f5454e1bf0ee0d75c43520b1fb25f6731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / django_ip_access-3.0.2-py3-none-any.whl

Download URL django_ip_access-3.0.2-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
616dddc36d4a33b0c294637795464c3260ec88d073a1aa743d4d7941906748df
BLAKE2b-256 checksum
How to use checksums
ae7eb36464e372ab7712aa4c62b8216ea8f5a1920c729b2521406a690e5d9e9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release history Release notifications | RSS feed

This release

3.0.2 This release

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page