Skip to content

feat: add option to prompt for database password on every connection#537

Merged
datlechin merged 3 commits intomainfrom
feat/prompt-for-password
Mar 31, 2026
Merged

feat: add option to prompt for database password on every connection#537
datlechin merged 3 commits intomainfrom
feat/prompt-for-password

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Closes #534

  • Adds a toggle in the connection form: "Ask for password on every connection"
  • When enabled, passwords are never saved to Keychain — user is prompted via native NSAlert modal each time they connect
  • Prompted password is cached in-memory for the session lifetime (auto-reconnect uses cache silently, app relaunch re-prompts)
  • Works for both database passwords and API tokens (BigQuery, D1, DynamoDB)

Implementation

File Change
DatabaseConnection.swift promptForPassword computed property via additionalFields
ConnectionSession.swift cachedPassword: String? in-memory session cache
PasswordPromptHelper.swift Native NSAlert + NSSecureTextField password prompt
PasswordPromptToggle.swift Extracted toggle + conditional SecureField view
DatabaseDriver.swift passwordOverride param on createDriver/resolvePassword
DatabaseManager.swift Prompt in connectToSession, cache in reconnect paths
ConnectionFormView.swift Toggle UI, save/load/test/validation
ConnectionStorage.swift Skip password copy in duplicateConnection
ConnectionSSLView.swift Fix pre-existing missing UniformTypeIdentifiers import

Edge cases handled

  • Save → Prompt switch: deletes existing Keychain password
  • Auto-reconnect: uses session-cached password silently
  • App relaunch: re-prompts (cache not persisted)
  • Cancel prompt: clean cancellation, no stale session
  • usePgpass mutual exclusion: toggling one disables the other
  • Duplicate connection: flag copied, password not copied

Test plan

  • Create new connection → toggle ON → save → connect → verify prompt appears, no Keychain entry
  • Edit existing connection → toggle ON → save → verify old Keychain password deleted
  • Toggle OFF → enter password → save → verify Keychain password saved again
  • Connect with prompt → kill DB → wait for auto-reconnect → verify no re-prompt
  • Quit app → relaunch → verify prompt appears on session restore
  • Duplicate a prompt-for-password connection → verify duplicate also prompts
  • Cancel prompt → verify clean state (no stuck connecting indicator)
  • Toggle usePgpass ON → verify promptForPassword disables, and vice versa
  • API-only connection (e.g. BigQuery) → verify toggle says "Ask for API token"

@datlechin datlechin merged commit 8adf763 into main Mar 31, 2026
2 checks passed
@datlechin datlechin deleted the feat/prompt-for-password branch March 31, 2026 09:00
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.

Add an option to prompt for the database user password

1 participant