Metadata-Version: 2.1
Name: django-allow-cidr
Version: 0.4.1
Summary: A Django Middleware to enable use of CIDR IP ranges in ALLOWED_HOSTS.
Home-page: https://github.com/mozmeao/django-allow-cidr
Author: Paul McLanahan
Author-email: pmac@mozilla.com
License: Apache Software License 2.0
Keywords: django-allow-cidr
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
License-File: LICENSE

=============================
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
--------

* The normal ``ALLOWED_HOSTS`` values will also work as intended. This Middleware is intended to augment,
  not replace, the normal Django function.
* If you do define ``ALLOWED_CIDR_NETS`` and it has values, the middleware will capture what you have in `ALLOWED_HOSTS`,
  set ``ALLOWED_HOSTS`` to `['*']` and take over validation of host headers.
* The ``ALLOWED_CIDR_NETS`` values can be any valid network definition for the `netaddr`_ package.

Running Tests
-------------

Does the code actually work?

::

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

Credits
-------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

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




History
-------

0.4.1 (2022-06-13)
++++++++++++++++++

* Use packaging.version to avoid distutils deprecated module - thanks @adamantike!

0.4.0 (2022-02-22)
++++++++++++++++++

* Drop Django support for non-LTS and non-latest Django (so, removing 1.x, 2.0, 2.1, 3.0, 3.1)
* Drop support for older Python releases (2.x, 3.5)
* Add Django 4.0 to tox's test matrix
* Add Python 3.7 through 3.10 to tox's test matrix; 3.6 to 3.10 are now the only tested versions
* Switch CI to Github Actions

0.3.1 (2018-07-31)
++++++++++++++++++

* Fix issue #6: Accept passed in `get_response` function for Middleware in Django >= 1.10.
* Publish updated docs that fix the `ALLOWED_CIDR_NETS` typo.

0.3.0 (2018-02-21)
++++++++++++++++++

* Disable middleware if ALLOWED_HOSTS is set to `['*']`.

0.2.0 (2018-02-21)
++++++++++++++++++

* Handle host names with ports (Thanks Giorgos!).

0.1.0 (2018-02-16)
++++++++++++++++++

* First release on PyPI.
