some changes to support saved queries for new TKO
-migration to add saved_queries table. this is different from the existing query_history table. this feature is incompatible with the old one and I didn't want to interfere with the old one.
-various modifications to history handling across the board to allow better support for saved queries (the url will show up as just "saved_query=123", without all the extra crap)
-refactoring of apache_auth.py to allow new TKO to use it without using all the Django auth crap
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1810 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/apache_auth.py b/frontend/apache_auth.py
index a74dda3..1c63f9e 100644
--- a/frontend/apache_auth.py
+++ b/frontend/apache_auth.py
@@ -42,12 +42,13 @@
return None
-class ApacheAuthMiddleware(object):
+class GetApacheUserMiddleware(object):
"""
Middleware for use when Apache is doing authentication. Looks for
- REQUEST_USER in requests and logs that user in. If no such header is
- found, looks for HTTP_AUTHORIZATION header with username to login (this
- allows CLI to authenticate).
+ REMOTE_USER in headers and passed the username found to
+ thread_local.set_user(). If no such header is found, looks for
+ HTTP_AUTHORIZATION header with username (this allows CLI to authenticate).
+ If neither of those are found, DEBUG_USER is used.
"""
def process_request(self, request):
@@ -60,8 +61,20 @@
if user is None:
# no user info - assume we're in development mode
user = DEBUG_USER
- user_object = auth.authenticate(username=user,
+ thread_local.set_user(user)
+
+
+class ApacheAuthMiddleware(GetApacheUserMiddleware):
+ """
+ Like GetApacheUserMiddleware, but also logs the user into Django's auth
+ system, and replaces the username in thread_local with the actual User model
+ object.
+ """
+
+ def process_request(self, request):
+ super(ApacheAuthMiddleware, self).process_request(request)
+ username = thread_local.get_user()
+ user_object = auth.authenticate(username=username,
password='')
auth.login(request, user_object)
- thread_local.set_user(models.User.objects.get(login=user))
- return None
+ thread_local.set_user(models.User.objects.get(login=username))