Skip to main content

A translatable password validator for django, based on zxcvbn-python.

Project description

django-zxcvbn-password-validator

A translatable password validator for django, based on zxcvbn-python and available with pip.

Unlike rule-based validators (minimum length, must contain a digit...), zxcvbn estimates actual password strength using pattern matching, common password dictionaries, and keyboard layout analysis. It provides meaningful, actionable feedback to help users create stronger passwords.

Professional support for django-zxcvbn-password-validator is available as part of the Tidelift Subscription

Build status Coverage Status PyPI version Published on Django Packages

How to use

Install the package:

pip install django-zxcvbn-password-validator

Add 'django_zxcvbn_password_validator' in the INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "django_zxcvbn_password_validator"
]

Modify AUTH_PASSWORD_VALIDATORS:

AUTH_PASSWORD_VALIDATORS = [
    {
        "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
    },
    {
        "NAME": "django_zxcvbn_password_validator.ZxcvbnPasswordValidator",
    },
    # ...
]

You could choose to use zxcvbn alone, but using it alongside Django's UserAttributeSimilarityValidator is recommended.

Finally, you can set the PASSWORD_MINIMAL_STRENGTH to your liking (default is 2), every password scoring lower than this number will be rejected:

# 0 too guessable: risky password. (guesses < 10^3)
# 1 very guessable: protection from throttled online attacks.
# (guesses < 10^6)
# 2 somewhat guessable: protection from unthrottled online attacks.
# (guesses < 10^8)
# 3 safely unguessable: moderate protection from offline slow-hash scenario.
# (guesses < 10^10)
# 4 very unguessable: strong protection from offline slow-hash scenario.
# (guesses >= 10^10)
PASSWORD_MINIMAL_STRENGTH = 0 if DEBUG else 4

If the password is not strong enough, we provide errors explaining what you need to do:

English example

The error messages are translated to your target language (even the strings given by zxcvbn that are in English only):

Translated example

Compatibility

Requires Django 2+ and Python 3.6+. Note that Python 3.6 and 3.7 are not tested in CI anymore (GitHub Actions no longer provides runners for them), so while they should work, there is no guarantee.

Translating the project

This project is available in 131 languages. Your contribution would be very appreciated if you know a language that is not yet available or if you want to improve an existing translation (especially AI-generated ones). See how to contribute

Translation status

Translators
  • Andrés Martano: Brazilian Portuguese
  • Lionel Sausin: French
  • Michal Čihař: Czech
  • Pierre Sassoulas: French
  • RViktor: Hungarian
  • Thom Wiggers: Dutch
  • Claude AI: Afrikaans, Akan, Albanian, Amharic, Arabic, Armenian, Assamese, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Brazilian Portuguese (corrections), Breton, Bulgarian, Burmese, Cantonese, Catalan, Cebuano, Chichewa, Chinese Simplified, Chinese Traditional, Corsican, Croatian, Danish, Esperanto, Estonian, Ewe, Faroese, Filipino, Finnish, Fulah, Galician, Georgian, German, Greek, Gujarati, Hausa, Hawaiian, Hebrew, Hindi, Icelandic, Igbo, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Kinyarwanda, Kirundi, Korean, Kurdish, Kyrgyz, Lao, Latin, Latvian, Lingala, Lithuanian, Luganda, Luxembourgish, Macedonian, Malagasy, Malay, Malayalam, Maltese, Maori, Marathi, Mongolian, Nepali, Northern Ndebele, Northern Sami, Norwegian Bokmål, Occitan, Odia, Oromo, Pashto, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Samoan, Sango, Sardinian, Scottish Gaelic, Serbian, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenian, Somali, Southern Ndebele, Spanish, Sundanese, Swahili, Swati, Swedish, Tajik, Tamil, Telugu, Thai, Tibetan, Tigrinya, Tongan, Tsonga, Tswana, Turkish, Turkmen, Twi, Ukrainian, Urdu, Uzbek, Venda, Vietnamese, Welsh, Western Frisian, Wolof, Xhosa, Yiddish, Yoruba, Zulu

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_zxcvbn_password_validator-1.6.0.tar.gz (304.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_zxcvbn_password_validator-1.6.0-py3-none-any.whl (432.3 kB view details)

Uploaded Python 3

File details

Details for the file django_zxcvbn_password_validator-1.6.0.tar.gz.

File metadata

File hashes

Hashes for django_zxcvbn_password_validator-1.6.0.tar.gz
Algorithm Hash digest
SHA256 5afd5d92313dd0e274817706a16211f0660ff771ec4fb3e6d79b2512d1308ff1
MD5 447f50474712d074bee86feb611534be
BLAKE2b-256 82cdc3b59802974beac681db2d93d72afe872fb8a7e892f557a60ec5a144c487

See more details on using hashes here.

File details

Details for the file django_zxcvbn_password_validator-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_zxcvbn_password_validator-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41d10997fb6325ed8f1d4694c8ebdeef760fb34994553df6f5603718035bb1b9
MD5 37c85b6a2d223a1727a8e467b00a762e
BLAKE2b-256 110b78be05d394e63d64925edaf37c149c4a47b39f4b22ac314c454235595fca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page