Django Auth IP Whitelist is a module for identity verification in Django applications, allowing login via IP address and offering whitelist functionality.
Project description
django-auth-ipwhitelist
Django Auth IP Whitelist is a module for identity verification in Django applications, allowing login via IP address and offering whitelist functionality.
This module enables users to authenticate themselves automatically using their IP address, eliminating the need for traditional username and password login methods. Additionally, it includes whitelist functionality to prohibit users outside the whitelist, enhancing security and control. By combining IP address login with whitelist capabilities, this module provides a simple, secure, and efficient identity verification mechanism for Django applications.
Installation
- Install useing pip:
pip install django-auth-ipwhitelist
Configuration
- Add django_auth_ipwhitelist to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'django_auth_ipwhitelist', ]
- Add django_auth_ipwhitelist.middleware.AuthIPWhitelistMiddleware to your MIDDLEWARE setting like this:
MIDDLEWARE = [ ... 'django_auth_ipwhitelist.middleware.IPWhitelistMiddleware', ]
- Add django_auth_ipwhitelist to your AUTHENTICATION_BACKENDS setting like this:
AUTHENTICATION_BACKENDS = [ ... 'django_auth_ipwhitelist.backends.IPAuthenticationBackend', ]
- Create authipwhitelist database tables by running the following command:
python manage.py migrate django_auth_ipwhitelist
- If you need to add default IP addresses to the whitelist, for example, for logging into the Django admin using the default address, you can achieve this by the following settings in settings.py. By default, 127.0.0.1 is already set as default whitelist addresses.
AUTH_IP_WHITELIST = { 'ALLOWED_WHITELISTED_HOSTS': [ '127.0.0.1', ], }
Usage
To use this module, simply add the IP address to the whitelist via the Django admin interface. Once the IP address is added to the whitelist, during authentication, the user instance will be retrieved based on the user information associated with the IP. If the user instance does not exist in the system, it will be created using the associated username. If a user attempts to access the application from an IP address not listed in the whitelist, they will be prompted that the IP is unauthorized.
Integration with djangorestframework-simplejwt
- This module allows seamless integration of django-auth-ipwhitelist with drf-simplejwt, enabling authentication based on IP whitelist directly through the JWT token, in addition to the traditional username/password mode. Here’s how to set it up:
# settings.py SIMPLE_JWT = { ... "TOKEN_OBTAIN_SERIALIZER": "django_auth_ipwhitelist.serializers.IPTokenObtainPairSerializer", }
History
0.1.0 (2024-03-18)
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-auth-ipwhitelist-0.1.0.tar.gz
.
File metadata
- Download URL: django-auth-ipwhitelist-0.1.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8762bee4fabf61961429c900a510eb043bef074c94e5a04c45ee992c55dde95d |
|
MD5 | 884267b5f9b5c9b75ba992eb38d76a9a |
|
BLAKE2b-256 | 3d1107d1d5d46e45040f295ad2816e00a6b3d645fc4ad9e0506ac79e8cc5597a |
File details
Details for the file django_auth_ipwhitelist-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_auth_ipwhitelist-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b077e49791964581bfcc9cdd3a3fcda033df3ad6521bcb3cf4fd7ab1d7b13a1 |
|
MD5 | 79096b8bc0089ba484550c35f91b6d6d |
|
BLAKE2b-256 | 3c8ec2218afe9fa9a4f84f80b2a6ee9a0276c186ddaf159984b24b7a2934d02c |