Skip to content

feat(api): log session/audit subject from UserAccessControl#4029

Merged
rchincha merged 1 commit into
project-zot:mainfrom
andaaron:audit2
May 1, 2026
Merged

feat(api): log session/audit subject from UserAccessControl#4029
rchincha merged 1 commit into
project-zot:mainfrom
andaaron:audit2

Conversation

@andaaron

@andaaron andaaron commented May 1, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SessionLogger to redact Authorization without decoding credentials and to log username from request context when present.
  • Update SessionAuditLogger to log subject from request context (defaulting to "anonymous" when unset).
  • Add session_test.go coverage for SessionLogger and SessionAuditLogger.

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.

Comment thread pkg/api/session_test.go
Comment thread pkg/api/session_test.go
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.55%. Comparing base (8f27949) to head (f0778f1).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andaaron
andaaron marked this pull request as ready for review May 1, 2026 14:41
@andaaron
andaaron requested a review from rchincha as a code owner May 1, 2026 14:41
@andaaron
andaaron requested a review from vrajashkr May 1, 2026 14:41
@rchincha
rchincha merged commit 7ec34a9 into project-zot:main May 1, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants