[1.4.X] Fixed #18118 -- Improved documentation for contrib.auth.hashers utility functions. Thanks Mathieu Agopian for the report and Ramiro Morales for the review.

Backport of r17905 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.4.X@17906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Claude Paroz 2012-04-13 11:40:44 +00:00
parent 3f77b84489
commit 2fa8b3f143
1 changed files with 12 additions and 6 deletions

View File

@ -427,6 +427,8 @@ checking passwords stored with PBKDF2SHA1, bcrypt_, SHA1_, etc. The next few
sections describe a couple of common ways advanced users may want to modify this sections describe a couple of common ways advanced users may want to modify this
setting. setting.
.. _bcrypt_usage:
Using bcrypt with Django Using bcrypt with Django
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
@ -772,7 +774,7 @@ Manually managing a user's password
to create and validate hashed password. You can use them independently to create and validate hashed password. You can use them independently
from the ``User`` model. from the ``User`` model.
.. function:: check_password() .. function:: check_password(password, encoded)
.. versionadded:: 1.4 .. versionadded:: 1.4
@ -783,18 +785,22 @@ Manually managing a user's password
user's ``password`` field in the database to check against, and returns user's ``password`` field in the database to check against, and returns
``True`` if they match, ``False`` otherwise. ``True`` if they match, ``False`` otherwise.
.. function:: make_password() .. function:: make_password(password[, salt, hashers])
.. versionadded:: 1.4 .. versionadded:: 1.4
Creates a hashed password in the format used by this application. It takes Creates a hashed password in the format used by this application. It takes
two arguments: hashing algorithm to use and the password in plain-text. one mandatory argument: the password in plain-text. Optionally, you can
Currently supported algorithms are: ``'sha1'``, ``'md5'`` and ``'crypt'`` provide a salt and a hashing algorithm to use, if you don't want to use the
if you have the ``crypt`` library installed. If the second argument is defaults (first entry of ``PASSWORD_HASHERS`` setting).
Currently supported algorithms are: ``'pbkdf2_sha256'``, ``'pbkdf2_sha1'``,
``'bcrypt'`` (see :ref:`bcrypt_usage`), ``'sha1'``, ``'md5'``,
``'unsalted_md5'`` (only for backward compatibility) and ``'crypt'``
if you have the ``crypt`` library installed. If the password argument is
``None``, an unusable password is returned (a one that will be never ``None``, an unusable password is returned (a one that will be never
accepted by :func:`django.contrib.auth.hashers.check_password`). accepted by :func:`django.contrib.auth.hashers.check_password`).
.. function:: is_password_usable() .. function:: is_password_usable(encoded_password)
.. versionadded:: 1.4 .. versionadded:: 1.4