Repository navigation
feat(connections): add reusable credential profiles shared across connections - #2876
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
# Conflicts: # CHANGELOG.md # TablePro/Core/Database/ConnectionCredentialResolver.swift # TablePro/Core/Storage/SSHProfileStorage.swift # TablePro/Views/ConnectionForm/ConnectionFormCoordinator.swift # TablePro/Views/ConnectionForm/ViewModels/AuthPaneViewModel.swift # TableProTests/Core/Storage/SSHProfileStorageTests.swift
This was referenced Sep 15, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2853. Builds on #2872, which is already merged.
A credential profile is one username and password that any number of connections point at. Rotating the password is one edit instead of one per connection, which is what the issue asked for.
The shape, and why it is not the SSH profile's
#2853 says to follow the reusable SSH profiles pattern. #2872 explains why that pattern is the wrong model to copy: it freezes the non-secret half into each connection and resolves only the secrets live, so a profile edit never reaches a linked connection's host or username.
So the link is
DatabaseConnection.credentialMode=.inline | .profile(id:)with no snapshot, and the username is kept current by a write-through fan-out inCredentialProfileStorage.updateProfile.The write-through is load-bearing rather than a convenience.
connection.usernameis read raw by the AWS IAM signer, the~/.pgpasslookup,NativeDumpRegistry's-U/-u/--username=flags,ExternalConnectionTrustKeyand the connection record pushed to iCloud. Blanking it for a linked connection would have pushed an empty username over the good value on a second Mac, becauseSyncRecordMapperwritesconnection.usernameon every connection sync while the new profile record is still inert.ConnectionCredentialResolver.resolveUsernamecovers the window before a fan-out has run.Storage
credentialProfiles.jsonsits besideconnections.jsonand is HMAC-stamped by the same key, not inUserDefaultswhere SSH profiles live. A credential profile can declare aPasswordSource.command(shell:), and that tag is the only thing between an attacker-writable file and a command this Mac never agreed to run.ConnectionCredentialResolverchecksCredentialProfileStorage.storeIsTrustedbefore running one, exactly as it checksConnectionStorage.storeIsTrustedfor a connection's own.IntegrityStampedFileStore<Element: Codable>is that read-verify-adopt and write-stamp cycle, extracted fromConnectionStoragerather than copied.ConnectionStorageadopts it in this PR, so there is one implementation to be right. Its load is three-valued on purpose: a file that will not decode is not an empty list, and saving over it would destroy what it held.The Keychain prefix is
com.TablePro.credprofile., notcom.TablePro.password.<profileId>. #2872 has the measurement: iOS sweeps that prefix and deletes any item whose trailing UUID is not a saved connection, and a profile id never is one.What a profile carries
Username, and the password as one of four modes: stored in the Keychain, asked for every time,
~/.pgpass, or aPasswordSource(file, environment variable, command output, 1Password, Vault, AWS Secrets Manager). Plus the plugin-declared secure fields an engine needs beyond a password, such as an AWS secret access key.There is deliberately no database type on the profile.
DatabaseDriverFactory.buildAdditionalFieldsalready loops oversecureConnectionFieldIds(for: connection.type), so a connection reads only the fields its own type declares and one profile can carry several engines' keys without a type constraint."Ask every time" asks once per profile per launch, not once per connection:
DatabaseManager.promptedPasswordsis keyed byConnectionCredentialResolver.promptCacheKey, which is the profile when there is one.UI
A new Profiles pane in Settings lists both kinds in one place, with the name, a summary and how many connections use each. Before this, profiles of either kind were reachable only from three small buttons inside a connection form's Network tab, with no list anywhere and no way to see what depended on one.
The connection form's Authentication section opens with a Credentials picker. Enter Below comes first so the menu is never empty and keeps today's behavior. Picking a profile replaces the username and password rows with a read-only summary. Save These as a Profile… promotes what is already filled in.
The Settings window goes from 720 to 800 points wide. Measured: eleven pane labels total 447pt of text, and a twelfth at the 20-24pt per-item padding a
.preferencetoolbar uses puts twelve items at 726-774pt, which is an overflow chevron at 720.Safety
PasswordSourcepayload never enters a CKRecord. A profile using one arrives on a second Mac set to ask instead.Sync
SyncRecordType.credentialProfileandCredentialProfileSyncFieldare declared with an emptyverifiedInProduction, exactly asFavoriteDatabaseis, andSyncSchemaGateTests.pendingProductionDeploylists it. The type is inert:CloudKitSyncEngine.pushwithholds it and the parity suites pass because its rawValue is absent fromCloudKit/production-schema.ckdb.Profiles do not sync yet, and the docs say so. The coordinator's push, pull and tombstone arms land in PR 3 alongside the schema flip. What this PR does carry is the one sync change the feature cannot ship without:
applyRemoteConnectionpreserves the localcredentialMode, because a connection record has no field for it and a remote update would otherwise decode as.inline, unlink the connection, and leave it with no password at all.Review
Two reviewers read this diff.
swiftui-profound seven, two of them behavioural: thePickerhad no tag matching a missing profile, so a connection bound to a profile this Mac does not have rendered as nothing selected; and the editor decoded the whole profiles file four times per body pass, which is once per keystroke, becauseIntegrityStampedFileStore.load()has no cache. The rest were accessibility identifiers, a stale list when a profile is created from a connection window, and the secure-field type opening on MySQL whatever the connection was.Codex found seventeen, nine of them P1, and all are fixed. The ones worth naming:
credentialProfiles.jsonwas adopted and stamped, which would sign a planted command-backed profile and mark it trusted.adoptsUnstampedis now opt-in and onlyconnections.jsonhas the pre-tag history that justifies it..sourceor.pgpassprofile left its connections with nothing, because only a stored password was carried across.secretsWereReadableis the same tri-state fix(connections): apply SSH profile edits and deletes to the connections that use them #2872 introduced for the connection form, applied here.SyncSchemaGateTestsbroke deterministically, which I had not run.Skill(security-review)then found two High-severity issues, both the same shape: a.command(shell:)from an untrusted profiles file being laundered into a trusted store. Both are fixed and pinned by tests.unlinkConnectionscopied a profile'spasswordSourceonto each connection, andconnections.jsonre-stamps itself trusted on the next save, so deleting an unfamiliar profile was the consent gesture that blessed the command. It now carries a source only from a file TablePro itself last wrote.save()stamped unconditionally, and a profile write is a read-modify-write over the whole list, so renaming your own profile re-signed everything else in the file.userSaveEstablishesTrustseparates the two stores:connections.jsonkeeps its documented behaviour where a save clears a tamper flag,credentialProfiles.jsonpersists edits without ever blessing what it did not write.It cleared the rest: the Keychain prefixes cannot collide, no secret reaches a log or a CKRecord, and the record type is genuinely inert. Its one sub-threshold note is that
promptedPasswordsis never pruned, so a prompted password outlives a disconnect in memory; it was already cached on the session before this change.I did not take its suggestion to apply the same save guard to
ConnectionStorage.saveConnections.DatabaseManager+TunnelCommand.swift:15-19documents re-saving a connection in the app as the intended way to clear its tamper flag, so that is a deliberate design outside this feature.Verification
verify.sh buildPASSverify.sh teston the suites owning every changed type: 78 cases, 78 passedswift teston the package's sync parity suitesverify.sh lint TablePro TableProTestsverify.sh docsNew tests:
CredentialProfileStorageTests(round trip, write-through, password stored once, delete converting to inline, tombstone ordering, refusing to delete when secrets are unreadable, refusing to overwrite a file that will not decode, the trust tag, duplicate sharing the link) andCredentialProfileSyncTests(inert while unverified, name round trip, and that a password source never survives a trip through CloudKit).Screenshots are placeholders
docs/images/settings-profiles{,-dark}.pnganddocs/images/credential-profile-picker{,-dark}.pngare placeholders at the right 1560x960, so the page renders. They need a real capture. I launched a sandboxed Debug build to take them and stopped: twoTableProprocesses were running, one of them the real app, andSystem Eventsdrives by process name, so the keystrokes could have landed in the wrong one.Not in this PR
Sync coordinator wiring, export/import, and iOS (PR 3).