Skip to main content

A Django reusable app that provides validators and a form field that checks the strength of a password

Project description

django-passwords is a reusable app that provides a form field and validators that check the strength of a password.

Installation

Compatibility

django-passwords is compatible with Django 1.3 through 1.9 RC1. Pythons 2.7 and 3.4 are both supported.

Settings

django-passwords adds 6 optional settings

Optional:

Specifies minimum length for passwords:

PASSWORD_MIN_LENGTH = 6 # Defaults to 6

Specifies maximum length for passwords:

PASSWORD_MAX_LENGTH = 120 # Defaults to None

Specifies the location of a dictionary (file with one word per line):

PASSWORD_DICTIONARY = "/usr/share/dict/words" # Defaults to None

Specifies how close a fuzzy match has to be to be considered a match:

PASSWORD_MATCH_THRESHOLD = 0.9 # Defaults to 0.9, should be 0.0 - 1.0 where 1.0 means exactly the same.

Specifies a list of common sequences to attempt to match a password against:

PASSWORD_COMMON_SEQUENCES = [] # Should be a list of strings, see passwords/validators.py for default

Specifies number of characters within various sets that a password must contain:

PASSWORD_COMPLEXITY = { # You can omit any or all of these for no limit for that particular set
    "UPPER": 1,        # Uppercase
    "LOWER": 1,        # Lowercase
    "LETTERS": 1,       # Either uppercase or lowercase letters
    "DIGITS": 1,       # Digits
    "SPECIAL": 1,      # Not alphanumeric, space or punctuation character
    "WORDS": 1         # Words (alphanumeric sequences separated by a whitespace or punctuation character)
}

Usage

To use the formfield simply import it and use it:

from django import forms
from passwords.fields import PasswordField

class ExampleForm(forms.Form):
    password = PasswordField(label="Password")

You can make use of the validators on your own fields:

from django import forms
from passwords.validators import dictionary_words

field = forms.CharField(validators=[dictionary_words])

You can also create custom validator instances to specify your own field-specific configurations, rather than using the global configurations:

from django import forms
from passwords.validators import (
    DictionaryValidator, LengthValidator, ComplexityValidator)

field = forms.CharField(validators=[
    DictionaryValidator(words=['banned_word'], threshold=0.9),
    LengthValidator(min_length=8),
    ComplexityValidator(complexities=dict(
        UPPER=1,
        LOWER=1,
        DIGITS=1
    )),
])

Django’s password validation API is slightly different than the form validation API and has wrappers in the auth_password_validators module:

AUTH_PASSWORD_VALIDATORS = [
    ,
    {"NAME": "passwords.auth_password_validators.ComplexityValidator"}
]

Project details


Download files

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

Source Distribution

django-strong-passwords-0.1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

django_strong_passwords-0.1.0-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file django-strong-passwords-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-strong-passwords-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7fab7ec62db531128e6cb9cbb7629027994adb8d7a924fb8f971b38f399c218c
MD5 0eaefa5e7329ae0d6d426188ecbffd11
BLAKE2b-256 640e5ea91a14fff7678a5dc10eda1d3b25739a1556d62c8ab7cbf67f226750ae

See more details on using hashes here.

File details

Details for the file django_strong_passwords-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_strong_passwords-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76359ee8e80e30d25e2e630d6ed72851ff17bcdba53ae875f3bccab7d4081cd0
MD5 53c841c8eb54453ce7713b00952ce842
BLAKE2b-256 77b1317119bbfa664c29e413bfbc673fb52cc47783ce0ff0f1a676d4dd750299

See more details on using hashes here.

Supported by

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