feat(api): log session/audit subject from UserAccessControl#4029
Conversation
There was a problem hiding this comment.
Pull request overview
Adds consistent session/audit identity logging by extracting the authenticated subject from request.Context() (via UserAccessControl) after handlers run, and introduces tests for the new behavior.
Changes:
- Update
SessionLoggerto redactAuthorizationwithout decoding credentials and to logusernamefrom request context when present. - Update
SessionAuditLoggerto logsubjectfrom request context (defaulting to"anonymous"when unset). - Add
session_test.gocoverage forSessionLoggerandSessionAuditLogger.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/api/session.go | Switch session/audit identity extraction to UserAccessControl from request context; simplify Authorization redaction. |
| pkg/api/session_test.go | Add tests validating audit subject behavior, query-string object logging, and Authorization redaction/username logging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Read identity from request context after handlers run so Basic, Bearer, OIDC, mTLS, etc. are covered; use subject "anonymous" when unset. Redact Authorization in SessionLogger without decoding credentials. Add session_test.go for SessionLogger and SessionAuditLogger. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4029 +/- ##
==========================================
- Coverage 91.56% 91.55% -0.01%
==========================================
Files 197 197
Lines 28410 28400 -10
==========================================
- Hits 26013 26003 -10
Misses 1546 1546
Partials 851 851 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Read identity from request context after handlers run so Basic, Bearer, OIDC, mTLS, etc. are covered; use subject "anonymous" when unset. Redact Authorization in SessionLogger without decoding credentials. Add session_test.go for SessionLogger and SessionAuditLogger.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.