django-auth-ipwhitelist


Namedjango-auth-ipwhitelist JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/Skylor-Tang/django-auth-ipwhitelist
SummaryDjango Auth IP Whitelist is a module for identity verification in Django applications, allowing login via IP address and offering whitelist functionality.
upload_time2024-03-22 02:27:32
maintainerNone
docs_urlNone
authortangmeijian
requires_python>=3.6
licenseBSD license
keywords django django_auth_ipwhitelist auth ipwhitelist whitelist ip login
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =======================
django-auth-ipwhitelist
=======================


.. image:: https://img.shields.io/pypi/v/django-auth-ipwhitelist.svg
        :target: https://pypi.python.org/pypi/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:
    .. code-block:: bash

        pip install django-auth-ipwhitelist

Configuration
-------------

Add `django_auth_ipwhitelist` to your `INSTALLED_APPS` setting like this:
    .. code-block:: python

        INSTALLED_APPS = [
             ...
             'django_auth_ipwhitelist',
        ]

Add `django_auth_ipwhitelist.middleware.AuthIPWhitelistMiddleware` to your `MIDDLEWARE` setting like this:
    .. code-block:: python

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

Add `django_auth_ipwhitelist` to your `AUTHENTICATION_BACKENDS` setting like this:
    .. code-block:: python

        AUTHENTICATION_BACKENDS = [
            ...
            'django_auth_ipwhitelist.backends.IPAuthenticationBackend',
        ]

Create `authipwhitelist` database tables by running the following command:
    .. code-block:: bash

        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.
    .. code-block:: python

        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:
    .. code-block:: python

        # settings.py
        SIMPLE_JWT = {
            ...
            "TOKEN_OBTAIN_SERIALIZER": "django_auth_ipwhitelist.serializers.IPTokenObtainPairSerializer",
        }



=======
History
=======

0.1.0 (2024-03-18)
------------------

* First release on PyPI.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Skylor-Tang/django-auth-ipwhitelist",
    "name": "django-auth-ipwhitelist",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "django, django_auth_ipwhitelist, auth, ipwhitelist, whitelist, ip, login",
    "author": "tangmeijian",
    "author_email": "tang1996mei@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/11/07d1d5d46e45040f295ad2816e00a6b3d645fc4ad9e0506ac79e8cc5597a/django-auth-ipwhitelist-0.1.0.tar.gz",
    "platform": null,
    "description": "=======================\ndjango-auth-ipwhitelist\n=======================\n\n\n.. image:: https://img.shields.io/pypi/v/django-auth-ipwhitelist.svg\n        :target: https://pypi.python.org/pypi/django-auth-ipwhitelist\n\n\nDjango Auth IP Whitelist is a module for identity verification in Django applications, allowing login via IP address and offering whitelist functionality.\n\nThis 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.\n\n\nInstallation\n------------\n\nInstall useing pip:\n    .. code-block:: bash\n\n        pip install django-auth-ipwhitelist\n\nConfiguration\n-------------\n\nAdd `django_auth_ipwhitelist` to your `INSTALLED_APPS` setting like this:\n    .. code-block:: python\n\n        INSTALLED_APPS = [\n             ...\n             'django_auth_ipwhitelist',\n        ]\n\nAdd `django_auth_ipwhitelist.middleware.AuthIPWhitelistMiddleware` to your `MIDDLEWARE` setting like this:\n    .. code-block:: python\n\n        MIDDLEWARE = [\n            ...\n            'django_auth_ipwhitelist.middleware.IPWhitelistMiddleware',\n        ]\n\nAdd `django_auth_ipwhitelist` to your `AUTHENTICATION_BACKENDS` setting like this:\n    .. code-block:: python\n\n        AUTHENTICATION_BACKENDS = [\n            ...\n            'django_auth_ipwhitelist.backends.IPAuthenticationBackend',\n        ]\n\nCreate `authipwhitelist` database tables by running the following command:\n    .. code-block:: bash\n\n        python manage.py migrate django_auth_ipwhitelist\n\nIf 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.\n    .. code-block:: python\n\n        AUTH_IP_WHITELIST = {\n            'ALLOWED_WHITELISTED_HOSTS': [\n                '127.0.0.1',\n            ],\n        }\n\nUsage\n-----\n\nTo 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.\n\n\nIntegration with djangorestframework-simplejwt\n----------------------------------------------\n\nThis 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:\n    .. code-block:: python\n\n        # settings.py\n        SIMPLE_JWT = {\n            ...\n            \"TOKEN_OBTAIN_SERIALIZER\": \"django_auth_ipwhitelist.serializers.IPTokenObtainPairSerializer\",\n        }\n\n\n\n=======\nHistory\n=======\n\n0.1.0 (2024-03-18)\n------------------\n\n* First release on PyPI.\n",
    "bugtrack_url": null,
    "license": "BSD license",
    "summary": "Django Auth IP Whitelist is a module for identity verification in Django applications, allowing login via IP address and offering whitelist functionality.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Skylor-Tang/django-auth-ipwhitelist"
    },
    "split_keywords": [
        "django",
        " django_auth_ipwhitelist",
        " auth",
        " ipwhitelist",
        " whitelist",
        " ip",
        " login"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c8ec2218afe9fa9a4f84f80b2a6ee9a0276c186ddaf159984b24b7a2934d02c",
                "md5": "79096b8bc0089ba484550c35f91b6d6d",
                "sha256": "4b077e49791964581bfcc9cdd3a3fcda033df3ad6521bcb3cf4fd7ab1d7b13a1"
            },
            "downloads": -1,
            "filename": "django_auth_ipwhitelist-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79096b8bc0089ba484550c35f91b6d6d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 10255,
            "upload_time": "2024-03-22T02:27:31",
            "upload_time_iso_8601": "2024-03-22T02:27:31.001915Z",
            "url": "https://files.pythonhosted.org/packages/3c/8e/c2218afe9fa9a4f84f80b2a6ee9a0276c186ddaf159984b24b7a2934d02c/django_auth_ipwhitelist-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d1107d1d5d46e45040f295ad2816e00a6b3d645fc4ad9e0506ac79e8cc5597a",
                "md5": "884267b5f9b5c9b75ba992eb38d76a9a",
                "sha256": "8762bee4fabf61961429c900a510eb043bef074c94e5a04c45ee992c55dde95d"
            },
            "downloads": -1,
            "filename": "django-auth-ipwhitelist-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "884267b5f9b5c9b75ba992eb38d76a9a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 14830,
            "upload_time": "2024-03-22T02:27:32",
            "upload_time_iso_8601": "2024-03-22T02:27:32.798869Z",
            "url": "https://files.pythonhosted.org/packages/3d/11/07d1d5d46e45040f295ad2816e00a6b3d645fc4ad9e0506ac79e8cc5597a/django-auth-ipwhitelist-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-22 02:27:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Skylor-Tang",
    "github_project": "django-auth-ipwhitelist",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-auth-ipwhitelist"
}
        
Elapsed time: 0.20014s