Skip to main content

Django ZXCVBN Password

Back-end and Front-end password validation with ZXCVBN.

A combination of pirandig’s django-zxcvbn and aj-may’s django-password-strength Django apps. It combines back-end and front-end validation with strength meter display.

License

Software licensed under ISC license.

Installation

pip install django-zxcvbn-password

Usage

# settings.py

AUTH_PASSWORD_VALIDATORS = [{
    'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
}, {
    'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
}, {
    'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
}, {
    'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
}, {
    'NAME': 'zxcvbn_password.ZXCVBNValidator',
    'OPTIONS': {
        'min_score': 3,
        'user_attributes': ('username', 'email', 'first_name', 'last_name')
    }
}]
# forms.py

from django import forms
from zxcvbn_password.fields import PasswordField, PasswordConfirmationField

class RegisterForm(forms.Form):
    password1 = PasswordField()
    password2 = PasswordConfirmationField(confirm_with=password1)

By default, other inputs won’t be used to compute the score, but you can enforce it like this:

# forms.py

from zxcvbn_password import zxcbnn

# in your form class
def clean():
    password = self.cleaned_data.get('password')
    other_field1 = ...
    other_field2 = ...

    if password:
        score = zxcvbn(password, [other_field1, other_field2])['score']
        # raise forms.ValidationError if needed

    return self.cleaned_data

Screen-shot

https://cloud.githubusercontent.com/assets/3999221/23079032/5ae1513a-f54b-11e6-9d66-90660ad5fb2d.png

Development

To run all the tests: tox

Changelog

2.0.0 (2017-02-17)

  • Drop Django 1.8 support in favor of AUTH_PASSWORD_VALIDATORS setting introduced in Django 1.9.

  • Update zxcvbn to more recent version (dwolfhub/zxcvbn-python on GitHub).

  • Update JavaScript code to latest version.

  • Remove all settings (they now go in AUTH_PASSWORD_VALIDATOR options).

  • Change license to ISC.

Thanks to Nick Stefan and Daniel Wolf.

1.1.0 (2016-10-18)

  • Cookiecutterize the project.

1.0.5 (2015-03-31)

  • I don’t remember.

1.0.3 (2015-03-12)

  • Switch README to rst.

  • Fix manifest rules.

1.0.2 (2015-03-12)

  • Change package name from django_zxcvbn_password to zxcvbn_password.

1.0.0 (2015-02-21)

  • Beta release on PyPI.

0.1.0 (2015-02-01)

  • Alpha release on PyPI.

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-2.0.0.tar.gz (416.3 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-2.0.0-py2.py3-none-any.whl (408.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-zxcvbn-password-2.0.0.tar.gz.

File metadata

File hashes

Hashes for django-zxcvbn-password-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a3176c92387b59f4188787ee0ea7459c7b3fbda177ef1892549e73aa8d7c5df7
MD5 0ae52e5c5bb008544def903b9be2edcb
BLAKE2b-256 0563d904c983d72a09291cb83736b5655e14fc7b892629513535a902aafd00b3

See more details on using hashes here.

File details

Details for the file django_zxcvbn_password-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_zxcvbn_password-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fde57e6b7f862e22024681b53423c0012d6f55d1260836ea9dc6679bd8dffe0f
MD5 6378f77f3b42aafe192c6d29794ae78e
BLAKE2b-256 f27954644a41c808ba466147e750b4285b03aaef63b99288323be66cd35471a5

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 Sentry Error logging StatusPage Status page