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
  • Unai Loidi: Basque
  • Claude AI: Afrikaans, Akan, Albanian, Amharic, Arabic, Armenian, Assamese, Azerbaijani, 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.1.tar.gz (304.9 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.1-py3-none-any.whl (432.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_zxcvbn_password_validator-1.6.1.tar.gz
Algorithm Hash digest
SHA256 660cc4af81210a3b50522d1f75285d053f0714d3e389af12d269e24ebf4ee59f
MD5 27d7966eee0902b9067e335d795fb720
BLAKE2b-256 9d1ef6333b063680ef8d2037c8dedce3c53efa6c34d07157e81834941ce548c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_zxcvbn_password_validator-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2124a01b03101e8aa670fe2beabc8bcce4887ade978149af6d853bff6dff039a
MD5 0c7be622fd4d4cc9537ab9f60da8c471
BLAKE2b-256 122a093ee2c9f0ca6575ab74f4958bf3517a976ed258a0fc32157e30a8312eb7

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