django-password-policies-validator


Namedjango-password-policies-validator JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryA Django app to validate password complexity and prevent users from reusing previous passwords.
upload_time2022-12-28 04:08:02
maintainer
docs_urlNone
author
requires_python>=3.8
licenseBSD 3-Clause License Copyright (c) 2022, ÌTHUÂNKHOKI 意傳科技 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords django password validator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================================
django-password-policies-validator
==================================

django-password-policies-validator is a Django app to validate password complexity and prevent users from reusing previous passwords.


Quick start
-----------

#. Add "password_policies" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...
        'password_policies',
    ]

#. Add validators to AUTH_PASSWORD_VALIDATORS setting::

    AUTH_PASSWORD_VALIDATORS = [
        ...
        {
            'NAME': 'password_policies.password_validation.ComplexityValidator',
        },
        {
            'NAME': 'password_policies.password_validation.ReusedPasswordValidator',
        },
        {
            'NAME': 'password_policies.password_validation.MinimumChangeIntervalValidator',
        },
    ]

#. Append ``PasswordExpirationMiddleware`` to MIDDLEWARE setting, note that this must be listed **after** the ``'django.contrib.auth.middleware.AuthenticationMiddleware'`` ::

    MIDDLEWARE = [
        ...
        'password_policies.middleware.PasswordExpirationMiddleware',
    ]

#. Run ``python manage.py migrate`` to create the ``PasswordRecord`` models.

#. Start the development server and go to the "Change password" page to check how the new password policies applied.


The ``Validator`` classes
-------------------------

Custom options can be passed into validators by the following syntax ::

    AUTH_PASSWORD_VALIDATORS = [
        ...
        {
            'NAME': 'password_policies.password_validation.ComplexityValidator',
            'OPTIONS': {
                'min_char_categories': 3,
                'min_numeric_chars': 2,
            }
        },
    ]

Available options of each validator and their default values are listed below.

``ComplexityValidator(min_char_categories=4, min_numeric_chars=1, min_uppercase_chars=1, min_lowercase_chars=1, min_special_chars=1)``
    Validates that the password is complex enough by checking how many categories of characters it contains, or the count of certain category of characters. Characters are devided into four categories:

    - Uppercase alphabet characters A-Z
    - Lowercase alphabet characters a-z
    - Numeric characters 0-9
    - Non-alphanumeric (special) characters

    ``min_char_categories``
        The minimum categories of characters that the password should contain out of the four categories above. Value should be between 1 and 4.

    ``min_numeric_chars``
        The minimum count of numeric characters that the password should contain. Value should be 0 or any positive integer.

    ``min_uppercase_chars``
        The minimum count of uppercase characters that the password should contain. Value should be 0 or any positive integer.

    ``min_lowercase_chars``
        The minimum count of lowercase characters that the password should contain. Value should be 0 or any positive integer.

    ``min_special_chars``
        The minimum count of special characters that the password should contain. Value should be 0 or any positive integer.

``ReusedPasswordValidator(record_length=3)``
    Remembers the user's previous *n* passwords and validate the new password doed not repeat any of them.

    ``record_length``
        The number of previous password records that the validator should compare against. Value should be any positive integer.

``MinimumChangeIntervalValidator(min_interval=1)``
    Prevent the user from changing the password again within certain period of time. This is to avoid the user to bypass ``ReusedPasswordValidator`` and reuse the old password by changing passwords repeatedly in a short period of time. 

    ``min_interval``
        The minimum time interval (in days) of two consecutive password change attempts. Value should be any positive interger or float.

The ``PasswordExpirationMiddleware`` class
------------------------------------------

``PasswordExpirationMiddleware``
    Checks the user's password-changing records, if the user's password is expired, redirect the user to the password-changing form and shows a warning message.

    This middleware works for any urls under the ``admin`` application namespace and redirects to the ``password_change`` url under the same namespace of the page which the user is redirected from. Urls not under the ``admin`` application namespace are not redirected.

    The password expires in 90 days by default, and the number can be set by providing setting ``PASSWORD_EXPIRATION_DAYS`` to an integer or float value in ``settings.py``.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-password-policies-validator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "django,password,validator",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/dc/f6/8f8b93797e7f5c1fc7e239b39d03794fd33bf4b9d841e9158c544742abf8/django-password-policies-validator-1.0.1.tar.gz",
    "platform": null,
    "description": "==================================\ndjango-password-policies-validator\n==================================\n\ndjango-password-policies-validator is a Django app to validate password complexity and prevent users from reusing previous passwords.\n\n\nQuick start\n-----------\n\n#. Add \"password_policies\" to your INSTALLED_APPS setting like this::\n\n    INSTALLED_APPS = [\n        ...\n        'password_policies',\n    ]\n\n#. Add validators to AUTH_PASSWORD_VALIDATORS setting::\n\n    AUTH_PASSWORD_VALIDATORS = [\n        ...\n        {\n            'NAME': 'password_policies.password_validation.ComplexityValidator',\n        },\n        {\n            'NAME': 'password_policies.password_validation.ReusedPasswordValidator',\n        },\n        {\n            'NAME': 'password_policies.password_validation.MinimumChangeIntervalValidator',\n        },\n    ]\n\n#. Append ``PasswordExpirationMiddleware`` to MIDDLEWARE setting, note that this must be listed **after** the ``'django.contrib.auth.middleware.AuthenticationMiddleware'`` ::\n\n    MIDDLEWARE = [\n        ...\n        'password_policies.middleware.PasswordExpirationMiddleware',\n    ]\n\n#. Run ``python manage.py migrate`` to create the ``PasswordRecord`` models.\n\n#. Start the development server and go to the \"Change password\" page to check how the new password policies applied.\n\n\nThe ``Validator`` classes\n-------------------------\n\nCustom options can be passed into validators by the following syntax ::\n\n    AUTH_PASSWORD_VALIDATORS = [\n        ...\n        {\n            'NAME': 'password_policies.password_validation.ComplexityValidator',\n            'OPTIONS': {\n                'min_char_categories': 3,\n                'min_numeric_chars': 2,\n            }\n        },\n    ]\n\nAvailable options of each validator and their default values are listed below.\n\n``ComplexityValidator(min_char_categories=4, min_numeric_chars=1, min_uppercase_chars=1, min_lowercase_chars=1, min_special_chars=1)``\n    Validates that the password is complex enough by checking how many categories of characters it contains, or the count of certain category of characters. Characters are devided into four categories:\n\n    - Uppercase alphabet characters A-Z\n    - Lowercase alphabet characters a-z\n    - Numeric characters 0-9\n    - Non-alphanumeric (special) characters\n\n    ``min_char_categories``\n        The minimum categories of characters that the password should contain out of the four categories above. Value should be between 1 and 4.\n\n    ``min_numeric_chars``\n        The minimum count of numeric characters that the password should contain. Value should be 0 or any positive integer.\n\n    ``min_uppercase_chars``\n        The minimum count of uppercase characters that the password should contain. Value should be 0 or any positive integer.\n\n    ``min_lowercase_chars``\n        The minimum count of lowercase characters that the password should contain. Value should be 0 or any positive integer.\n\n    ``min_special_chars``\n        The minimum count of special characters that the password should contain. Value should be 0 or any positive integer.\n\n``ReusedPasswordValidator(record_length=3)``\n    Remembers the user's previous *n* passwords and validate the new password doed not repeat any of them.\n\n    ``record_length``\n        The number of previous password records that the validator should compare against. Value should be any positive integer.\n\n``MinimumChangeIntervalValidator(min_interval=1)``\n    Prevent the user from changing the password again within certain period of time. This is to avoid the user to bypass ``ReusedPasswordValidator`` and reuse the old password by changing passwords repeatedly in a short period of time. \n\n    ``min_interval``\n        The minimum time interval (in days) of two consecutive password change attempts. Value should be any positive interger or float.\n\nThe ``PasswordExpirationMiddleware`` class\n------------------------------------------\n\n``PasswordExpirationMiddleware``\n    Checks the user's password-changing records, if the user's password is expired, redirect the user to the password-changing form and shows a warning message.\n\n    This middleware works for any urls under the ``admin`` application namespace and redirects to the ``password_change`` url under the same namespace of the page which the user is redirected from. Urls not under the ``admin`` application namespace are not redirected.\n\n    The password expires in 90 days by default, and the number can be set by providing setting ``PASSWORD_EXPIRATION_DAYS`` to an integer or float value in ``settings.py``.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2022, \u00ccTHU\u00c2NKHOKI \u610f\u50b3\u79d1\u6280  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "A Django app to validate password complexity and prevent users from reusing previous passwords.",
    "version": "1.0.1",
    "split_keywords": [
        "django",
        "password",
        "validator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "af314e9048c5043c9ce917100a776b64",
                "sha256": "ab291a0124cdc7cbd43169736c5a4c63dc8f7e7d0c298a2879a9f36f0be73f84"
            },
            "downloads": -1,
            "filename": "django-password-policies-validator-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "af314e9048c5043c9ce917100a776b64",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7434,
            "upload_time": "2022-12-28T04:08:02",
            "upload_time_iso_8601": "2022-12-28T04:08:02.576211Z",
            "url": "https://files.pythonhosted.org/packages/dc/f6/8f8b93797e7f5c1fc7e239b39d03794fd33bf4b9d841e9158c544742abf8/django-password-policies-validator-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-28 04:08:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "django-password-policies-validator"
}
        
Elapsed time: 0.02562s