mozmeao / django-allow-cidr

A Django Middleware to enable use of CIDR IP ranges in ALLOWED_HOSTS.
Other
98 stars 15 forks source link

============================= Django Allow CIDR

.. image:: https://badge.fury.io/py/django-allow-cidr.svg :target: https://badge.fury.io/py/django-allow-cidr

.. image:: https://github.com/mozmeao/django-allow-cidr/actions/workflows/ci.yml/badge.svg :target: https://github.com/mozmeao/django-allow-cidr/actions

A Django Middleware to enable use of CIDR IP ranges in ALLOWED_HOSTS.

Quickstart

Install Django Allow CIDR::

pip install django-allow-cidr

Add the Middleware to your MIDDLEWARE settings. It should be the first in the list:

.. code-block:: python

MIDDLEWARE = (
    'allow_cidr.middleware.AllowCIDRMiddleware',
    ...
)

Add the ALLOWED_CIDR_NETS setting:

.. code-block:: python

ALLOWED_CIDR_NETS = ['192.168.1.0/24']

Profit!

Features

Running Tests

Does the code actually work?

::

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Pushing to PyPI

Cutting a new Github Release will trigger CI checks, followed by an automatic release to PyPI, using the release version. Please make sure that your Github Release version matches the project version in __init__.py.

For more details see the release job in .github/workflows/ci.yml.

Credits

Tools used in rendering this package:

.. _netaddr: https://netaddr.readthedocs.io/en/latest/ .. Cookiecutter: https://github.com/audreyr/cookiecutter .. cookiecutter-djangopackage: https://github.com/pydanny/cookiecutter-djangopackage