summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-06-08 13:27:47 -0400
committerTim Graham <timograham@gmail.com>2015-06-10 07:41:01 -0400
commit55b3bd84681a87266f6bef72480aaef48a7c295f (patch)
tree4413b39f348f0a0d017db07c182ec4e0af8e6f24 /docs
parenta0047c6242fd48068eb444e0a58f7a5d2bc1bcd3 (diff)
Refs #16860 -- Minor edits and fixes to password validation.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/settings.txt8
-rw-r--r--docs/releases/1.9.txt6
-rw-r--r--docs/topics/auth/passwords.txt30
3 files changed, 26 insertions, 18 deletions
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index a0c3e69877..126f8f17fb 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -2774,11 +2774,11 @@ AUTH_PASSWORD_VALIDATORS
.. versionadded:: 1.9
-Default: ``[]``
+Default: ``[]`` (Empty list)
-Sets the validators that are used to check the strength of user's passwords.
-See :ref:`password-validation` for more details.
-By default, no validation is performed and all passwords are accepted.
+The list of validators that are used to check the strength of user's passwords.
+See :ref:`password-validation` for more details. By default, no validation is
+performed and all passwords are accepted.
.. _settings-messages:
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 1054699bf9..5be8f233b5 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -28,7 +28,7 @@ What's new in Django 1.9
Password validation
~~~~~~~~~~~~~~~~~~~
-Django now offers password validation, to help prevent the usage of weak
+Django now offers password validation to help prevent the usage of weak
passwords by users. The validation is integrated in the included password
change and reset forms and is simple to integrate in any other code.
Validation is performed by one or more validators, configured in the new
@@ -36,10 +36,10 @@ Validation is performed by one or more validators, configured in the new
Four validators are included in Django, which can enforce a minimum length,
compare the password to the user's attributes like their name, ensure
-passwords aren't entirely numeric or check against an included list of common
+passwords aren't entirely numeric, or check against an included list of common
passwords. You can combine multiple validators, and some validators have
custom configuration options. For example, you can choose to provide a custom
-list of common passwords. Each validator provides a help text to explain their
+list of common passwords. Each validator provides a help text to explain its
requirements to the user.
By default, no validation is performed and all passwords are accepted, so if
diff --git a/docs/topics/auth/passwords.txt b/docs/topics/auth/passwords.txt
index 090c9196b6..69634cf314 100644
--- a/docs/topics/auth/passwords.txt
+++ b/docs/topics/auth/passwords.txt
@@ -242,6 +242,10 @@ from the ``User`` model.
Password validation
===================
+.. module:: django.contrib.auth.password_validation
+
+.. versionadded:: 1.9
+
Users often choose poor passwords. To help mitigate this problem, Django
offers pluggable password validation. You can configure multiple password
validators at the same time. A few validators are included in Django, but it's
@@ -254,14 +258,14 @@ Validators can also have optional settings to fine tune their behavior.
Validation is controlled by the :setting:`AUTH_PASSWORD_VALIDATORS` setting.
By default, validators are used in the forms to reset or change passwords.
-The default for setting is an empty list, which means no validators are
+The default for the setting is an empty list, which means no validators are
applied. In new projects created with the default :djadmin:`startproject`
template, a simple set of validators is enabled.
.. note::
Password validation can prevent the use of many types of weak passwords.
- However, the fact that a password passes all the validators, doesn't
+ However, the fact that a password passes all the validators doesn't
guarantee that it is a strong password. There are many factors that can
weaken a password that are not detectable by even the most advanced
password validators.
@@ -344,7 +348,7 @@ Django includes four validators:
`Mark Burnett <https://xato.net/passwords/more-top-worst-passwords/>`_.
The ``password_list_path`` can be set to the path of a custom file of
- common passwords. This file should contain one password per line, and
+ common passwords. This file should contain one password per line and
may be plain text or gzipped.
.. class:: NumericPasswordValidator()
@@ -354,8 +358,6 @@ Django includes four validators:
Integrating validation
-----------------------
-.. module:: django.contrib.auth.password_validation
-
There are a few functions in ``django.contrib.auth.password_validation`` that
you can call from your own forms or other code to integrate password
validation. This can be useful if you use custom forms for password setting,
@@ -368,14 +370,14 @@ or if you have API calls that allow passwords to be set, for example.
:exc:`~django.core.exceptions.ValidationError` with all the error messages
from the validators.
- The user object is optional: if it's not provided, some validators may not
- be able to perform any validation and will accept any password.
+ The ``user`` object is optional: if it's not provided, some validators may
+ not be able to perform any validation and will accept any password.
.. function:: password_changed(password, user=None, password_validators=None)
Informs all validators that the password has been changed. This can be used
- by some validators, e.g. a validator that prevents password reuse. This
- should be called once the password has been successfully changed.
+ by validators such as one that prevents password reuse. This should be
+ called once the password has been successfully changed.
.. function:: password_validators_help_texts(password_validators=None)
@@ -440,11 +442,17 @@ Here's a basic example of a validator, with one optional setting::
def validate(self, password, user=None):
if len(password) < self.min_length:
- raise ValidationError(_("This password is too short."))
+ raise ValidationError(
+ _("This password must contain at least %(min_length)d characters."),
+ code='password_too_short',
+ params={'min_length': self.min_length},
+ )
def get_help_text(self):
- return _("Your password must contain at least %(min_length)d characters.")
+ return _(
+ "Your password must contain at least %(min_length)d characters."
% {'min_length': self.min_length}
+ )
You can also implement ``password_changed(password, user=None``), which will
be called after a successful password change. That can be used to prevent