Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Project Description

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)

Note

Remember to include {{ form.media }} in your template. Please refer to the documentation of the two upstream repositories for more information.

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

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.
Release History

Release History

This version
History Node

2.0.0

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

v1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_zxcvbn_password-2.0.0-py2.py3-none-any.whl (408.9 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Feb 20, 2017
django-zxcvbn-password-2.0.0.tar.gz (416.3 kB) Copy SHA256 Checksum SHA256 Source Feb 20, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting