A Django reusable app that provides validators and a form field that checks the strength of a password
Project description
django-strong-passwords is a Django application that provides a form field and validators that check the strength of a password. It is a fork of django-passwords which adds support for modern versions of Django and Python.
Installation
pip install django-strong-passwords
Compatibility
django-strong-passwords is tested with Django 3.2+ and Python 3.7+.
Settings
django-strong-passwords adds 6 optional settings
- Optional:
Specifies minimum length for passwords:
PASSWORD_MIN_LENGTH = 6 # Defaults to 6Specifies maximum length for passwords:
PASSWORD_MAX_LENGTH = 120 # Defaults to NoneSpecifies the location of a dictionary (file with one word per line):
PASSWORD_DICTIONARY = "/usr/share/dict/words" # Defaults to NoneSpecifies 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 defaultSpecifies 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_strong_passwords-0.1.4.tar.gz.
File metadata
- Download URL: django_strong_passwords-0.1.4.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa3b9155c477509e76995c7eebcf7e55a844af3cdfb0018db3e78b5e1bd6baf8
|
|
| MD5 |
054d7ee74d97b10025e14235d988ea64
|
|
| BLAKE2b-256 |
032f30770cbb6ec3269db537d0aef06d12da4f758b11e6a3d826bcf3c71e6d84
|
Provenance
The following attestation bundles were made for django_strong_passwords-0.1.4.tar.gz:
Publisher:
release.yaml on brhelwig/django-strong-passwords
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_strong_passwords-0.1.4.tar.gz -
Subject digest:
aa3b9155c477509e76995c7eebcf7e55a844af3cdfb0018db3e78b5e1bd6baf8 - Sigstore transparency entry: 1119361875
- Sigstore integration time:
-
Permalink:
brhelwig/django-strong-passwords@1ee7e5e1d18718c6199ecbcc28c1b2f23dd1de5c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/brhelwig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@1ee7e5e1d18718c6199ecbcc28c1b2f23dd1de5c -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_strong_passwords-0.1.4-py3-none-any.whl.
File metadata
- Download URL: django_strong_passwords-0.1.4-py3-none-any.whl
- Upload date:
- Size: 36.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91d72922d229ff79448c0c24305455eea45ab9a459096ae5c43e012203ab4c37
|
|
| MD5 |
feed34fda2907ea459f1cf3582d672e0
|
|
| BLAKE2b-256 |
57413575ba1eaab88a6f06b72efcb93772a9b4beb11ccca85eb9872d39dfcf39
|
Provenance
The following attestation bundles were made for django_strong_passwords-0.1.4-py3-none-any.whl:
Publisher:
release.yaml on brhelwig/django-strong-passwords
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_strong_passwords-0.1.4-py3-none-any.whl -
Subject digest:
91d72922d229ff79448c0c24305455eea45ab9a459096ae5c43e012203ab4c37 - Sigstore transparency entry: 1119361948
- Sigstore integration time:
-
Permalink:
brhelwig/django-strong-passwords@1ee7e5e1d18718c6199ecbcc28c1b2f23dd1de5c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/brhelwig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@1ee7e5e1d18718c6199ecbcc28c1b2f23dd1de5c -
Trigger Event:
push
-
Statement type: