summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorJoonas Häkkinen <joonashak@proton.me>2025-02-19 14:36:06 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-02-20 16:12:28 +0100
commit87c5de3b7f2316aa17353d74f54e6ff19013d049 (patch)
tree90cff21dbc74f4fbe75ff1de23be0892d657d1a4 /docs/howto
parent43766c70bd2939771b7f37104866316faa34606b (diff)
Fixed #36200 -- Clarified MIDDLEWARE setting updates when using a custom RemoteUserMiddleware.
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/auth-remote-user.txt17
1 files changed, 15 insertions, 2 deletions
diff --git a/docs/howto/auth-remote-user.txt b/docs/howto/auth-remote-user.txt
index f8492e367a..254a141b45 100644
--- a/docs/howto/auth-remote-user.txt
+++ b/docs/howto/auth-remote-user.txt
@@ -76,14 +76,27 @@ regardless of ``AUTHENTICATION_BACKENDS``.
If your authentication mechanism uses a custom HTTP header and not
``REMOTE_USER``, you can subclass ``RemoteUserMiddleware`` and set the
-``header`` attribute to the desired ``request.META`` key. For example::
+``header`` attribute to the desired ``request.META`` key. For example:
+
+.. code-block:: python
+ :caption: ``mysite/middleware.py``
from django.contrib.auth.middleware import RemoteUserMiddleware
- class CustomHeaderMiddleware(RemoteUserMiddleware):
+ class CustomHeaderRemoteUserMiddleware(RemoteUserMiddleware):
header = "HTTP_AUTHUSER"
+This custom middleware is then used in the :setting:`MIDDLEWARE` setting
+instead of :class:`django.contrib.auth.middleware.RemoteUserMiddleware`::
+
+ MIDDLEWARE = [
+ "...",
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
+ "mysite.middleware.CustomHeaderRemoteUserMiddleware",
+ "...",
+ ]
+
.. warning::
Be very careful if using a ``RemoteUserMiddleware`` subclass with a custom