fix username logging in uwsgi for requests with TokenAuthentication#14322
fix username logging in uwsgi for requests with TokenAuthentication#14322fopina wants to merge 3 commits intoDefectDojo:bugfixfrom
Conversation
valentijnscholten
left a comment
There was a problem hiding this comment.
I think this will work. Do you have some log captures to "prove" it's working?
|
Mentioned the test criteria so it could be validated but forgot to include the actual logs, I’ll add them later today 👍 |
|
Description updated with sample log lines Also committed a unit test to cover it |
🔴 Risk threshold exceeded.This pull request modifies a sensitive file (dojo/middleware.py), triggering a configured "Configured Codepaths Edit" warning and suggesting review or configuration of sensitive paths and allowed authors in .dryrunsecurity.yaml. No explicit blocking action is set, but the change is flagged as failing the risk threshold and should be reviewed.
🔴 Configured Codepaths Edit in
|
| Vulnerability | Configured Codepaths Edit |
|---|---|
| Description | Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml. |
We've notified @mtesauro.
All finding details can be found in the DryRun Security Dashboard.
Description
dd_useris the variable we can use in uWSGI logging to log the username on each request, defaulting to-when not authenticated.However,
dd_useris currently not set for DRF / TokenAuthentication requests because DRF only runs after all the middlewares and LoginRequiredMiddleware is the one injecting dd_userThis PR fixes that by setting
dd_userafter response, when DRF was already executed and user is defined.Test results
dd_user is already part of
DD_UWSGI_LOGFORMAT_DEFAULTVisit http://localhost:8081/api/v2/users in the browser, username is logged (admin in test)
curl http://localhost:8081/api/v2/users -H 'Authorization: Token xxxx'and username is logged as-(not authenticated)With this PR, both cases log the username (firefox and curl user-agents)
Checklist
This checklist is for your information.
dev.dev.bugfixbranch.