Thursday, December 30, 2010

Django not seeing AuthenticationMiddleware for some reason ...

I am baffled, and it's probably something simple I'm missing ...
I just need to send a message for help and then I'll see it ...
(maybe ... ;)

My set up:
* apache2 on Ubuntu 10.04
* mod_wsgi 3.3, compiled with python 2.6.5 (the system python)
(but Ubuntu's mod_wsgi package was apparently not the problem)
* django installed in a virtualenv with python 2.6.5 also
* 2 django apps, one running on ':80' virtual host and one on
':8000' virtual host, each with a separate wsgi script (of course)
* apache server config (apache.conf) has WSGIPythonHome directive:
'WSGIPythonHome [path to virtualenv directory]'
* virtualenv directory has python interpreter in its bin dir and
python packages installed in its lib dir, including all django
libs
* I have verified that AuthenticationMiddleware can be imported
successfully from the command line within the virtualenv using
the virtualenv's python intepreter
* both django apps live within the virtualenv directory,
each in its own "project" directory there
* both apps are configured in apache with WSGIDaemonProcess directive

The error I continue to get is:

"ImproperlyConfigured at /

"The Django remote user auth middleware requires the
authentication middleware to be installed. Edit your
MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' before
the RemoteUserMiddleware class."

The relevant sections of the settings.py files for the apps are:
--------------
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
---------------

Ultimately I'll be using Active Directory (Kerberos) auth, but for
purposes of testing the REMOTE_USER stuff I've configured Basic
Authentication, and it is working (I authenticate successfully
before seeing that error message).

One thing that puzzles me is that in spite of a WSGIPythonHome
directive that points to the virtualenv, the error message lists
the "Python Executable" as "/usr/bin/python". The "Python Path"
shown in the error message seems correct: it includes the
virtualenv's site-packages directory, which is where django is
installed (there is no system-level django installed, Ubuntu's or
otherwise), and as I say I tested that the middleware classes
that the error message complains about can be imported using the
virtualenv's python interpreter on the command line.

Any suggestions welcome! (I can send the whole error page if it
would help, but I'll need to launder it a little.)

TIA!
Steve

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment