Skip to content

fix: persist rotated saved password and correct manager session state#10178

Open
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10128-saved-password-update
Open

fix: persist rotated saved password and correct manager session state#10178
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10128-saved-password-update

Conversation

@kundansable

@kundansable kundansable commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

For a server configured to save its password, entering a rotated password at the reconnect/password-prompt dialog appeared to work for the current connection but never actually replaced the stale saved ciphertext, causing an infinite re-prompt loop on every subsequent connection (e.g. opening the Query Tool).

Two gaps caused this:

  1. Query Tool's "already connected" reconnect path (sqleditor.connect_server) cached the freshly entered password on the in-memory server manager only, never writing it back to the stored server record.

  2. The main "Connect to Server" flow (ServerNode.connect()) only persisted a freshly entered password to the server's stored ciphertext when the current request's save_password flag was true. But the password-prompt dialog shown on a failed connect doesn't resend the server's existing save_password setting -- it only reports its own checkbox state, which defaults to unchecked -- so a server already configured to save its password never got its stale ciphertext replaced. Separately, the driver's in-memory manager.password fix was never persisted via manager.update_session(); Driver.managers is an in-process cache, so in a multi-worker deployment (e.g. OpenShift/Helm) the next request can land on a different worker, which restores the stale pre-fix manager from the session and loses the corrected password.

Fix all three: persist the new password to the (owned or shared) server record from the Query Tool reconnect path when save_password is set and allowed; treat save_password as true in the main connect flow whenever the server already has it enabled, not just when the current request's flag says so; and call manager.update_session() after a successful connect that used a freshly entered password.

Fixes #10128

Summary by CodeRabbit

  • Bug Fixes
    • Fixed repeated password prompts caused by outdated saved-password settings.
    • Preserved corrected passwords across requests and sessions after successful connections.
    • Saved newly entered passwords when the save-password option is enabled, including shared server connections.

For a server configured to save its password, entering a rotated
password at the reconnect/password-prompt dialog appeared to work
for the current connection but never actually replaced the stale
saved ciphertext, causing an infinite re-prompt loop on every
subsequent connection (e.g. opening the Query Tool).

Two gaps caused this:

1. Query Tool's "already connected" reconnect path
   (sqleditor.connect_server) cached the freshly entered password on
   the in-memory server manager only, never writing it back to the
   stored server record.

2. The main "Connect to Server" flow (ServerNode.connect()) only
   persisted a freshly entered password to the server's stored
   ciphertext when the current request's save_password flag was
   true. But the password-prompt dialog shown on a failed connect
   doesn't resend the server's existing save_password setting -- it
   only reports its own checkbox state, which defaults to
   unchecked -- so a server already configured to save its password
   never got its stale ciphertext replaced. Separately, the driver's
   in-memory manager.password fix was never persisted via
   manager.update_session(); Driver.managers is an in-process cache,
   so in a multi-worker deployment (e.g. OpenShift/Helm) the next
   request can land on a different worker, which restores the stale
   pre-fix manager from the session and loses the corrected
   password.

Fix all three: persist the new password to the (owned or shared)
server record from the Query Tool reconnect path when save_password
is set and allowed; treat save_password as true in the main connect
flow whenever the server already has it enabled, not just when the
current request's flag says so; and call manager.update_session()
after a successful connect that used a freshly entered password.

Fixes pgadmin-org#10128
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review 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: Pro Plus

Run ID: 0d21bb7f-d59d-471a-946a-abb35b4bf204

📥 Commits

Reviewing files that changed from the base of the PR and between b15c745 and 6966dbe.

📒 Files selected for processing (2)
  • web/pgadmin/browser/server_groups/servers/__init__.py
  • web/pgadmin/tools/sqleditor/__init__.py

Walkthrough

The connection flow now preserves saved-password settings and manager session state. Query Tool connections encrypt prompted passwords, cache them in the server manager, and optionally persist them to owned or shared server records.

Changes

Saved password flow

Layer / File(s) Summary
Connection state preservation
web/pgadmin/browser/server_groups/servers/__init__.py
Connection requests retain the server’s existing save_password setting when omitted and persist updated manager password state after successful connections.
Query Tool password persistence
web/pgadmin/tools/sqleditor/__init__.py
connect_server passes the server into password caching, which encrypts and caches prompted passwords and conditionally persists them to the correct server record.

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

Possibly related PRs

Suggested reviewers: asheshv, dpage

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: persisting rotated saved passwords and correcting manager session state.
Linked Issues check ✅ Passed The changes update saved-password persistence and session caching, which addresses #10128's repeated password prompt behavior.
Out of Scope Changes check ✅ Passed All changes stay within Query Tool/server connection password handling and session consistency.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

Update of saved passwords fails in Query Tool on 9-16

1 participant