Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with Django RemoteUserMiddleware RemoteUserBackend with fresh database
    primarykey
    data
    text
    <p>The 1.3 release of Django includes the <code>RemoteUserMiddleware</code> and <code>RemoteUserBackend</code> classes to allow Apache to do authentication. See <a href="http://docs.djangoproject.com/en/dev/howto/auth-remote-user/" rel="nofollow">http://docs.djangoproject.com/en/dev/howto/auth-remote-user/</a></p> <p>I have an initial_data.json that creates a superuser when syncdb is performed. A dumpdata confirms it.</p> <p>But I find that it doesn't seem to login properly with the newly created database. I get an ImproperlyConfigured exception that says: The Django remote user auth middleware requires the authentication middleware to be installed. </p> <pre><code>Edit your MIDDLEWARE_CLASSES setting to insert django.contrib.auth.middleware.AuthenticationMiddleware' before the RemoteUserMiddleware class. </code></pre> <p>The traceback points to <code>RemoteMilddleware.process_request()</code>:</p> <pre><code>def process_request(self, request): # AuthenticationMiddleware is required so that request.user exists. if not hasattr(request, 'user'): raise ImproperlyConfigured(... </code></pre> <p>The DEBUG output from Apache shows that settings in fact have <code>AuthenticationMiddleware</code> and <code>RemoteUserMiddleware</code> in the requested order:</p> <pre><code>MIDDLEWARE_CLASSES ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.RemoteUserMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') </code></pre> <p>But the request.user attribute is not set, generating the exception.</p> <p>If I look closer at the source code for django.contrib.auth.backends and middleware, I find that <code>AuthenticationMiddleware</code> is registering <code>LazyUser</code> for the request class. But <code>RemoteUserBackend</code> doesn't seem to have the authenticate() method called which is where remote_user gets looked up in the Users table.</p> <p>Is there something I should be doing to get <code>authenticate()</code> to be called in order to create request.user?</p> <p>I can provide more info as needed. This is using SSL, by the way. Does that have some interaction that I didn't anticipate?</p> <p>I should mention that I'm using Apache2.2.14 and <code>mod_wsgi</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload