Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dojo/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
uwsgi = __import__("uwsgi", globals(), locals(), ["set_logvar"], 0)
# this populates dd_user log var, so can appear in the uwsgi logs
uwsgi.set_logvar("dd_user", str(request.user))
request.META["REMOTE_USER"] = str(request.user)
return response


Expand Down Expand Up @@ -338,3 +339,4 @@
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)

6 changes: 6 additions & 0 deletions dojo/remote_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading