|
According to http://docs.djangoproject.com/en/dev/howto/auth-remote-user/ you can automatically create and login a user simply by setting the username in the HTTP variable REMOTE_USER and making the following modifications (the bold text is what I've added): In settings.py: MIDDLEWARE_CLASSES = [
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'forum.middleware.extended_user.ExtendedUser',
'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'forum.middleware.request_utils.RequestUtils',
'forum.middleware.cancel.CancelActionMiddleware',
'forum.middleware.admin_messages.AdminMessagesMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
]
...... AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.RemoteUserBackend',] OSQA/Django is not creating and logging in the user. Am I missing something? I know that the HTTP variable REMOTE_USER is actually set because it appears in log/django.osqa.log. |
|
The last piece of the puzzle, using helpful hint from http://meta.osqa.net/questions/5508/integration-with-existing-django-installation-how-to-deal-with-existing-users In forum/middleware/extended_user.py:
|
Things went further along when I changed REMOTE_USER to HTTP_ REMOTE_ USER.
The user is created in the
auth_usertable, and has no email, no password, is_active = 1.I get this error, though:
EXCEPTION INFO: Traceback (most recent call last): File "/opt/ActivePython-2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/opt/OSQA/forum/modules/decorators.py", line 95, in decorated return decoratable(*args, **kwargs) File "/opt/OSQA/forum/modules/decorators.py", line 55, in __call__ res = self._callable(*args, **kwargs) File "/opt/OSQA/forum/views/readers.py", line 89, in index paginator_context=paginator_context) File "/opt/OSQA/forum/views/readers.py", line 167, in question_list questions = questions.filter(~Q(tags__id__in = request.user.marked_tags.filter(user_selections__reason = 'bad'))) AttributeError: 'User' object has no attribute 'marked_tags'Good news, I got quite for now by changing the ordering of MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = [ 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.RemoteUserMiddleware', 'django.middleware.common.CommonMiddleware', 'forum.middleware.extended_user.ExtendedUser', 'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware', 'forum.middleware.request_utils.RequestUtils', 'forum.middleware.cancel.CancelActionMiddleware', 'forum.middleware.admin_messages.AdminMessagesMiddleware', 'django.middleware.transaction.TransactionMiddleware', ]Django will automatically create users in the database if the user doesn't exist.
Django will login users that have been created using the signup page.
OSQA will not login users that have been automatically created.
How do I create the appropriate entries in forum_user and forum_subscriptionsettings ?