The release of Django version 1.3 includes RemoteUserMiddlewareand
RemoteUserBackendto allow Apache to authenticate. See http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
I have initial_data.json that creates a superuser when syncdb is executed. Dampada confirms this.
But I find that it does not seem to fit correctly in the newly created database. I get an ImproperlyConfigured exception that says: Django remote user middleware needs to install authentication middleware.
Edit your MIDDLEWARE_CLASSES setting to insert django.contrib.auth.middleware.AuthenticationMiddleware' before the RemoteUserMiddleware class.
Tracking indicates RemoteMilddleware.process_request():
def process_request(self, request):
if not hasattr(request, 'user'):
raise ImproperlyConfigured(...
DEBUG output from Apache shows that actually have a setting AuthenticationMiddlewareand RemoteUserMiddlewarein the requested order:
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')
But the request.user attribute is not set, throwing an exception.
If I look closer to the source code for django.contrib.auth.backends and middleware, I find that I AuthenticationMiddlewareregister LazyUserfor the request class. But RemoteUserBackendit does not seem to have the authenticate () method called, in which the remote_defender is looked up in the Users table.
Is there something I have to do to call authenticate()request.user to create?
I can provide more information as needed. By the way, this is the use of SSL. Is there an interaction that I did not expect?
I must mention that I use Apache2.2.14 and mod_wsgi.