Skip to main content

Access a Django app with authorized IP address

Project description

django-ip-access

Python 3.11 Django 4.2 Python CI codecov Code style: black

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',
    ...
)

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:

pytest

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_access-2.2.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

django_ip_access-2.2.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file django_ip_access-2.2.0.tar.gz.

File metadata

  • Download URL: django_ip_access-2.2.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for django_ip_access-2.2.0.tar.gz
Algorithm Hash digest
SHA256 b8d0912a49ed6504d66662fb0030f477f574fb10e58f50f10d40b8bee8b98a11
MD5 399fa01b1210a33ca14ff462b866bfd6
BLAKE2b-256 749f2ac28ab53e1fae023e7b61046fb62227b72e34142c8ee3501b90b062a16e

See more details on using hashes here.

File details

Details for the file django_ip_access-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ip_access-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e0035fc7eff170407861000486cf856afe6fcb4ecc5972a79c0153b9e4697a7
MD5 02ae284c16a43347875971f37cabc290
BLAKE2b-256 9417931ead1e0cf3a122676d92f5f27ecdf10ab2f7963f33e03818c57e5f0290

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