[Django] #26623: Customizing environment variable for for RemoteUserMiddleware requires subclass

14 views
Skip to first unread message

Django

unread,
May 17, 2016, 3:58:59 AM5/17/16
to django-...@googlegroups.com
#26623: Customizing environment variable for for RemoteUserMiddleware requires
subclass
------------------------------+--------------------
Reporter: adelton | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------
Currently, when deploying Django project and the environment variable for
external authentication is different than the default `REMOTE_USER` like
in environment behind HTTP proxy environment where the data comes in HTTP
request headers and is seen as `HTTP_REMOTE_USER` or `HTTP_X_REMOTE_USER`,
the way to "configure" Django is to subclass the `RemoteUserMiddleware` or
`PersistentRemoteUserMiddleware`.

Coding the configuration with a class and then enabling it in
`settings.py` is a hurdle especially in devops environments.

Since the `RemoteUserMiddleware` already depends on externally set
environment variable for operation, here's a proposal to make the
environment variable name externally configurable as well, with
`DJANGO_REMOTE_USER_VAR`. That way the specifics of the external
environment can be configured in the configuration of that external
environment, like Apache HTTP Server configuration, without the admins
having to work with Python code. I propose update of the
`RemoteUserMiddleware` behaviour because that way it can be consumed by
subclasses as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/26623>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 17, 2016, 4:20:18 AM5/17/16
to django-...@googlegroups.com
#26623: Customizing environment variable for for RemoteUserMiddleware requires
subclass
------------------------------+--------------------------------------

Reporter: adelton | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by adelton):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


Comment:

Proposed patch at https://github.com/django/django/pull/6616.

--
Ticket URL: <https://code.djangoproject.com/ticket/26623#comment:1>

Django

unread,
May 19, 2016, 10:52:27 PM5/19/16
to django-...@googlegroups.com
#26623: Customizing environment variable for RemoteUserMiddleware requires subclass
------------------------------+--------------------------------------

Reporter: adelton | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/26623#comment:2>

Django

unread,
May 20, 2016, 10:35:09 AM5/20/16
to django-...@googlegroups.com
#26623: Customizing environment variable for RemoteUserMiddleware requires subclass
------------------------------+--------------------------------------

Reporter: adelton | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by aaugustin):

I'm not sure what's wrong with:

{{{
class CustomRemoteUserMiddleware(RemoteUserMiddleware):
header = os.environ['DJANGO_REMOTE_USER_VAR']
}}}

Features are usually configured with settings in Django. In "devops
environments" these settings are initialized from environment variables.

I'm -0 on adding a setting to tackle this specific use case and -1 on
using a environment variable that won't be visible e.g. in `diffsettings`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26623#comment:3>

Django

unread,
May 20, 2016, 7:15:24 PM5/20/16
to django-...@googlegroups.com
#26623: Customizing environment variable for RemoteUserMiddleware requires subclass
------------------------------+--------------------------------------
Reporter: adelton | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: 1.9
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by carljm):

* status: new => closed
* resolution: => wontfix


Comment:

I fully agree with Aymeric, but I'll go one step further and close the
ticket: I just don't think this use case is common enough to deserve its
own built-in setting. If you need it, it's easy enough to add the class to
your project once, and then never have to think about it again.

--
Ticket URL: <https://code.djangoproject.com/ticket/26623#comment:4>

Django

unread,
Dec 28, 2017, 12:11:55 PM12/28/17
to django-...@googlegroups.com
#26623: Customizing environment variable for RemoteUserMiddleware requires subclass
-------------------------------+--------------------------------------
Reporter: Jan Pazdziora | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: 1.9
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Jan Pazdziora):

For the record, `django-identity-external` in https://github.com/adelton
/django-identity-external / https://pypi.python.org/pypi/django-identity-
external implements this functionality in external middleware.

--
Ticket URL: <https://code.djangoproject.com/ticket/26623#comment:5>

Reply all
Reply to author
Forward
0 new messages