Middleware for logging the session user in Apache. This sets the username
information so that Apache is aware of the logged in user and can log
the username in the access_log (just like when the user is logged in
with basic authentication).
def process_request(self, request):
# AuthenticationMiddleware is required so that request.user exists
if not hasattr(request, 'user'):
"LogRemoteUserMiddleware requires AuthenticationMiddleware"
" to be in MIDDLEWARE_CLASSES before LogRemoteUserMiddleware.")
# set the REMOTE_USER variable if a user is logged in
# specific for mod_python
if isinstance(request, ModPythonRequest):
request._req.user = str(request.user.username)