Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
26d118c3
Kaydet (Commit)
26d118c3
authored
Nis 18, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Moved RemoteUserBackend documentation to reference guide.
üst
11ac50b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
49 deletions
+41
-49
auth-remote-user.txt
docs/howto/auth-remote-user.txt
+7
-49
auth.txt
docs/ref/contrib/auth.txt
+34
-0
No files found.
docs/howto/auth-remote-user.txt
Dosyayı görüntüle @
26d118c3
...
...
@@ -2,8 +2,6 @@
Authentication using ``REMOTE_USER``
====================================
.. currentmodule:: django.contrib.auth.backends
This document describes how to make use of external authentication sources
(where the Web server sets the ``REMOTE_USER`` environment variable) in your
Django applications. This type of authentication solution is typically seen on
...
...
@@ -22,7 +20,8 @@ When the Web server takes care of authentication it typically sets the
Django, ``REMOTE_USER`` is made available in the :attr:`request.META
<django.http.HttpRequest.META>` attribute. Django can be configured to make
use of the ``REMOTE_USER`` value using the ``RemoteUserMiddleware`` and
``RemoteUserBackend`` classes found in :mod:`django.contrib.auth`.
:class:`~django.contrib.auth.backends.RemoteUserBackend` classes found in
:mod:`django.contrib.auth`.
Configuration
=============
...
...
@@ -40,7 +39,8 @@ First, you must add the
)
Next, you must replace the :class:`~django.contrib.auth.backends.ModelBackend`
with ``RemoteUserBackend`` in the :setting:`AUTHENTICATION_BACKENDS` setting::
with :class:`~django.contrib.auth.backends.RemoteUserBackend` in the
:setting:`AUTHENTICATION_BACKENDS` setting::
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
...
...
@@ -48,7 +48,7 @@ with ``RemoteUserBackend`` in the :setting:`AUTHENTICATION_BACKENDS` setting::
With this setup, ``RemoteUserMiddleware`` will detect the username in
``request.META['REMOTE_USER']`` and will authenticate and auto-login that user
using the
``RemoteUserBackend`
`.
using the
:class:`~django.contrib.auth.backends.RemoteUserBackend
`.
.. note::
Since the ``RemoteUserBackend`` inherits from ``ModelBackend``, you will
...
...
@@ -64,48 +64,6 @@ If your authentication mechanism uses a custom HTTP header and not
class CustomHeaderMiddleware(RemoteUserMiddleware):
header = 'HTTP_AUTHUSER'
``RemoteUserBackend``
=====================
.. class:: django.contrib.auth.backends.RemoteUserBackend
If you need more control, you can create your own authentication backend
that inherits from ``RemoteUserBackend`` and overrides certain parts:
Attributes
~~~~~~~~~~
.. attribute:: RemoteUserBackend.create_unknown_user
``True`` or ``False``. Determines whether or not a
:class:`~django.contrib.auth.models.User` object is created if not already
in the database. Defaults to ``True``.
Methods
~~~~~~~
.. method:: RemoteUserBackend.authenticate(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
``User`` object if :attr:`~RemoteUserBackend.create_unknown_user` is
``True``.
Returns ``None`` if :attr:`~RemoteUserBackend.create_unknown_user` is
``False`` and a ``User`` object with the given username is not found in the
database.
.. method:: RemoteUserBackend.clean_username(username)
Performs any cleaning on the ``username`` (e.g. stripping LDAP DN
information) prior to using it to get or create a
:class:`~django.contrib.auth.models.User` object. Returns the cleaned
username.
.. method:: RemoteUserBackend.configure_user(user)
Configures a newly created user. This method is called immediately after a
new user is created, and can be used to perform custom setup actions, such
as setting the user's groups based on attributes in an LDAP directory.
Returns the user object.
that inherits from :class:`~django.contrib.auth.backends.RemoteUserBackend` and
override one or more of its attributes and methods.
docs/ref/contrib/auth.txt
Dosyayı görüntüle @
26d118c3
...
...
@@ -433,3 +433,37 @@ The following backends are available in :mod:`django.contrib.auth.backends`:
:attr:`request.META['REMOTE_USER'] <django.http.HttpRequest.META>`. See
the :doc:`Authenticating against REMOTE_USER </howto/auth-remote-user>`
documentation.
If you need more control, you can create your own authentication backend
that inherits from this class and override these attributes or methods:
.. attribute:: RemoteUserBackend.create_unknown_user
``True`` or ``False``. Determines whether or not a
:class:`~django.contrib.auth.models.User` object is created if not already
in the database. Defaults to ``True``.
.. method:: RemoteUserBackend.authenticate(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
``User`` object if :attr:`~RemoteUserBackend.create_unknown_user` is
``True``.
Returns ``None`` if :attr:`~RemoteUserBackend.create_unknown_user` is
``False`` and a ``User`` object with the given username is not found in the
database.
.. method:: RemoteUserBackend.clean_username(username)
Performs any cleaning on the ``username`` (e.g. stripping LDAP DN
information) prior to using it to get or create a
:class:`~django.contrib.auth.models.User` object. Returns the cleaned
username.
.. method:: RemoteUserBackend.configure_user(user)
Configures a newly created user. This method is called immediately after a
new user is created, and can be used to perform custom setup actions, such
as setting the user's groups based on attributes in an LDAP directory.
Returns the user object.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment