diff --git a/dojo/middleware.py b/dojo/middleware.py index 8d274202f90..8ec43f05586 100644 --- a/dojo/middleware.py +++ b/dojo/middleware.py @@ -338,3 +338,4 @@ def _trigger_async_index_update(self, model_groups): for i, batch in enumerate(batches, 1): logger.debug(f"AsyncSearchContextMiddleware: Triggering batch {i}/{len(batches)} for {model_name}: {len(batch)} instances") update_watson_search_index_for_model(model_name, batch) + diff --git a/dojo/remote_user.py b/dojo/remote_user.py index 2362a05ad30..8b285188d0f 100644 --- a/dojo/remote_user.py +++ b/dojo/remote_user.py @@ -43,6 +43,12 @@ def process_request(self, request): settings.AUTH_REMOTEUSER_TRUSTED_PROXY) return None + def process_response(self, request, response): + # Set REMOTE_USER so uWSGI logs the username correctly for all auth methods + if hasattr(request, "user") and request.user and request.user.is_authenticated: + request.META["REMOTE_USER"] = request.user.username + return response + class PersistentRemoteUserMiddleware(RemoteUserMiddleware): # same as https://github.com/django/django/blob/6654289f5b350dfca3dc4f6abab777459b906756/django/contrib/auth/middleware.py#L128