From 4b9330ccc04575f9e5126529ec355a450d12e77c Mon Sep 17 00:00:00 2001 From: Aleksej Manaev Date: Mon, 11 Jul 2016 16:40:39 +0200 Subject: Fixed #25187 -- Made request available in authentication backends. --- docs/ref/contrib/auth.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/contrib/auth.txt b/docs/ref/contrib/auth.txt index f12b16daa0..38f18b6dc8 100644 --- a/docs/ref/contrib/auth.txt +++ b/docs/ref/contrib/auth.txt @@ -518,7 +518,7 @@ The following backends are available in :mod:`django.contrib.auth.backends`: implement them other than returning an empty set of permissions if ``obj is not None``. - .. method:: authenticate(username=None, password=None, **kwargs) + .. method:: authenticate(request, username=None, password=None, **kwargs) Tries to authenticate ``username`` with ``password`` by calling :meth:`User.check_password @@ -528,6 +528,14 @@ The following backends are available in :mod:`django.contrib.auth.backends`: `. Returns an authenticated user or ``None``. + ``request`` is an :class:`~django.http.HttpRequest` and may be ``None`` + if it wasn't provided to :func:`~django.contrib.auth.authenticate` + (which passes it on to the backend). + + .. versionchanged:: 1.11 + + The ``request`` argument was added. + .. method:: get_user_permissions(user_obj, obj=None) Returns the set of permission strings the ``user_obj`` has from their @@ -603,7 +611,7 @@ The following backends are available in :mod:`django.contrib.auth.backends`: :class:`~django.contrib.auth.models.User` object is created if not already in the database. Defaults to ``True``. -.. method:: RemoteUserBackend.authenticate(remote_user) +.. method:: RemoteUserBackend.authenticate(request, remote_user) The username passed as ``remote_user`` is considered trusted. This method simply returns the ``User`` object with the given username, creating a new @@ -614,6 +622,10 @@ The following backends are available in :mod:`django.contrib.auth.backends`: ``False`` and a ``User`` object with the given username is not found in the database. + ``request`` is an :class:`~django.http.HttpRequest` and may be ``None`` if + it wasn't provided to :func:`~django.contrib.auth.authenticate` (which + passes it on to the backend). + .. method:: RemoteUserBackend.clean_username(username) Performs any cleaning on the ``username`` (e.g. stripping LDAP DN -- cgit v1.3