Skip to content

Try to remember username and inject it on logout - #10410

Open
albundy83 wants to merge 1 commit into
pgadmin-org:masterfrom
albundy83:fix-username-missing-logout
Open

Try to remember username and inject it on logout#10410
albundy83 wants to merge 1 commit into
pgadmin-org:masterfrom
albundy83:fix-username-missing-logout

Conversation

@albundy83

@albundy83 albundy83 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hello,

here a fix to add missing username when clicking on Logout button (GET on /logout)
Fix issue #10409

Summary by CodeRabbit

  • Bug Fixes

    • Preserved authenticated usernames in remote-user headers during logout.
    • Continued sanitizing usernames for encoding compatibility and removal of non-printable characters.
    • Prevented spoofed remote-user headers from persisting for anonymous requests.
    • Ensured authenticated-user logging can be disabled through configuration.
  • Tests

    • Added coverage for authentication, logout, anonymous requests, configuration, and username sanitization.

Signed-off-by: Grégoire Bellon-Gervais <gregoire.bellon-gervais@docaposte.fr>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7c90e846-30a7-482f-adee-bb5cfde53f9a

📥 Commits

Reviewing files that changed from the base of the PR and between fd9179f and ee7dbde.

📒 Files selected for processing (2)
  • web/pgadmin/__init__.py
  • web/pgadmin/browser/tests/test_log_authenticated_user.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The request hooks now preserve the authenticated username in g before logout and use it to populate X-Remote-User. Tests cover authentication states, configuration, Latin-1 transliteration, and control-character filtering.

Changes

Authenticated header logging

Layer / File(s) Summary
Header capture and response handling
web/pgadmin/__init__.py
The request hooks store the authenticated username before logout and use it as a fallback when setting X-Remote-User. Existing transliteration and character filtering remain in place.
Header behavior validation
web/pgadmin/browser/tests/test_log_authenticated_user.py
Tests cover authenticated users, logout, anonymous requests, disabled logging, Latin-1 transliteration, and control-character removal.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: asheshv

Merge Risk: ⚪ Minimal · up to ee7db

The logout response now retains the authenticated username for header logging while preserving anonymous-header removal and sanitization behavior. No concrete merge-blocking risk is established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: remembering the username and injecting it during logout.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant