Log REMOTE_USER (patron identifier) in uwsgi access logs#3146
Open
jonathangreen wants to merge 4 commits intomainfrom
Open
Log REMOTE_USER (patron identifier) in uwsgi access logs#3146jonathangreen wants to merge 4 commits intomainfrom
jonathangreen wants to merge 4 commits intomainfrom
Conversation
Set REMOTE_USER from the Basic auth username on the WSGI environ so uwsgi can log the patron identifier. Update the uwsgi log format to include %(var.REMOTE_USER) in place of the hardcoded dash. Only applies to Basic auth requests to avoid logging sensitive bearer tokens.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3146 +/- ##
=======================================
Coverage 93.26% 93.26%
=======================================
Files 493 493
Lines 45579 45583 +4
Branches 6252 6254 +2
=======================================
+ Hits 42511 42515 +4
Misses 1982 1982
Partials 1086 1086 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Sets
REMOTE_USERon the WSGI environ and updates the uwsgi log format to include it. This makes the patron identifier (library card barcode) visible in uwsgi access logs, aiding in troubleshooting authentication issues.REMOTE_USERto the submitted username before authentication, so it appears in logs even on failed 401 requestsREMOTE_USERfrompatron.authorization_identifierafter successful authentication-in the uwsgi log format with%(var.REMOTE_USER)Motivation and Context
This would have helped while troubleshooting CM authentication errors. Without the patron identifier in access logs, it's difficult to correlate failed requests to specific patrons when investigating issues.
How Has This Been Tested?
tox -e py312-docker -- --no-cov tests/manager/api/controller/test_base.pyChecklist