• Stars
    star
    249
  • Rank 162,050 (Top 4 %)
  • Language
    Python
  • License
    BSD 2-Clause "Sim...
  • Created over 13 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

https://travis-ci.org/dstufft/django-passwords.svg?branch=master

Django Passwords

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

Installation

You can install django-passwords with pip by typing:

pip install django-passwords

Or with easy_install by typing:

easy_install django-passwords

Or manually by downloading a tarball and typing:

python setup.py install

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"}
]

More Repositories

1

django-postmark

Django EmailBackend and Models/Views for integrating with Postmark
Python
46
star
2

dj-search-url

Python
21
star
3

dj-redis-url

Use Redis URLs in your Django Application.
Python
15
star
4

potpie

Translation Utility to Create Pseudo Translations of PO Files
Python
15
star
5

travis-example

10
star
6

divergent

Python
8
star
7

pep-packaging

Python
7
star
8

http11

A HTTP/1.1 parser.
C
7
star
9

crust

Framework for Tastypie API Clients
Python
7
star
10

cargocult

cargocult creates Python packages without the boilerplate or "cargo culting".
Python
6
star
11

fenrir

Fenrir is an asynchronous HTTP server for Python
Python
6
star
12

pypi-show-urls

A simple command line app to explore what urls need to be fetched to install a particular package
Python
6
star
13

jutils

A collection of jingo helpers for various purposes.
Python
5
star
14

stein

Stein is an asynchronous HTTP server and web framework
Python
5
star
15

pypi-stats

Python
4
star
16

xmlrpc2

Revamped xmlrpc library for Python
Python
4
star
17

Flask-Redistore

Python
4
star
18

guard

WSGI Middlewares for Web Application Security
Python
4
star
19

django-blockedemails

Python
4
star
20

caremad.io

My Personal Website
CSS
3
star
21

pypi.linkcheck

Python
3
star
22

hyde-slimmer

Python
3
star
23

psycopg2cffi-compat

Python
3
star
24

fastly-py

An API client for Fastly
Python
3
star
25

recliner

Python
3
star
26

pvr

Python
3
star
27

stockpile

A File Storage Abstraction that handles file systems and object stores.
Makefile
2
star
28

dotfiles

My dotfiles
Shell
2
star
29

converge

Python
2
star
30

pinax-settings

Example layout for a proposed change to Pinax Settings Layout
Python
2
star
31

django-staticfiles-mediafinder

2
star
32

packaging-old

Python
2
star
33

hyde-zipper

A Hyde Post Processor that precompresses files with Gzip
Python
2
star
34

pep-metadata

PEP describing Metadata 1.3
2
star
35

pypi-code

A WIP Proof of Concept of a Monorepo for PyPI
Starlark
2
star
36

tuf-serialization

Python
2
star
37

AnonymousPosting

[Xenofox] Anonymous Posting Addon for Xenforo
PHP
2
star
38

pypi-tests

Acceptance Testing for Any Python Package Repository
1
star
39

twelve

12factor inspired settings for a variety of backing services archetypes
Python
1
star
40

lessc

Python
1
star
41

django-pgenum

Python
1
star
42

testhooks

1
star
43

cookiecutter-pypackage

Python
1
star
44

wat

1
star
45

personal-peps

Finished or in progress PEPs
1
star
46

django-wontfix

1
star
47

evilgenius

My Personal Site
Python
1
star
48

distlib

Python
1
star
49

pypi-externals

A simple webapp to show what urls are scraped when you install a package from PyPI
Python
1
star
50

storages

Python
1
star
51

picohttpparser

Python
1
star
52

ebert

Python
1
star
53

pyramid_csrf

Python
1
star