Skip to main content

Django Password Validators

CI status

Additional libraries for validating passwords in Django 3.2 or later.

The application works well under python 4.x and 3.x versions.

Django version after the number 1.9, allows you to configure password validation. Configuration validation is placed under the variable AUTH_PASSWORD_VALIDATORS.

Installation

Just install django-password-validators via pip:

$ pip install django-password-validators

Validators

UniquePasswordsValidator

Validator checks if the password was once used by a particular user. If the password is used, then an exception is thrown, of course.

For each user, all the passwords are stored in a database. All passwords are strongly encrypted.

Configuration…

In the file settings.py we add

 INSTALLED_APPS = [
     ...
     'django_password_validators',
     'django_password_validators.password_history',
     ...
 ]

AUTH_PASSWORD_VALIDATORS = [
    ...
    {
        'NAME': 'django_password_validators.password_history.password_validation.UniquePasswordsValidator',
        'OPTIONS': {
             # How many recently entered passwords matter.
             # Passwords out of range are deleted.
             # Default: 0 - All passwords entered by the user. All password hashes are stored.
            'last_passwords': 5 # Only the last 5 passwords entered by the user
        }
    },
    ...
]

# If you want, you can change the default hasher for the password history.
# DPV_DEFAULT_HISTORY_HASHER = 'django_password_validators.password_history.hashers.HistoryHasher'

And run

python manage.py migrate

PasswordCharacterValidator

The validator checks for the minimum number of characters of a given type.

In the file settings.py we add

 INSTALLED_APPS = [
     ...
     'django_password_validators',
     ...
 ]

AUTH_PASSWORD_VALIDATORS = [
    ...
    {
        'NAME': 'django_password_validators.password_character_requirements.password_validation.PasswordCharacterValidator',
        'OPTIONS': {
             'min_length_digit': 1,
             'min_length_alpha': 2,
             'min_length_special': 3,
             'min_length_lower': 4,
             'min_length_upper': 5,
             'special_characters': "~!@#$%^&*()_+{}\":;'[]"
         }
    },
    ...
]

Metadata

Release files for django-password-validators 1.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-password-validators 1.7.3
File Size Uploaded
django-password-validators-1.7.3.tar.gz 19.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-password-validators 1.7.3
File Interpreter ABI Platform
django_password_validators-1.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 58.5 kB

Release files / django-password-validators-1.7.3.tar.gz

Download URL django-password-validators-1.7.3.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7175aefa6e86dc002dd3539327bf2d752097651704927dc409a669259e0d2195
BLAKE2b-256 checksum
How to use checksums
639182e0404483a5e2c0f3fdc144db39874b59107ed6a4a00afecf0c9d204a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / django_password_validators-1.7.3-py3-none-any.whl

Download URL django_password_validators-1.7.3-py3-none-any.whl
Size 39.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f243a82957e9b17a0c7cf5580f9d7588471cb6530c2dce7ee4e1222dddfe5768
BLAKE2b-256 checksum
How to use checksums
d8f9c83f378a46535c4851df45bc9d172f262c5a7df75575b9087a8fe1ae2af7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.7.3 This release

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

1 release file

1.0.0

3 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.5

3 release files

0.1.4

3 release files

0.1.2

3 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page