fix(connection-form): show Username field for MongoDB and other optional-auth databases#1266
Merged
Merged
Conversation
…nal-auth databases
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.
Problem
A MongoDB connection to an auth-enabled server connects "successfully" but the sidebar table list shows
[13] Command listCollections requires authentication. Compass connects to the same server fine.The connection form never showed a Username field for MongoDB, so the connection saved with an empty username.
Root cause
MongoDBPlugindeclaresrequiresAuthentication = false(correct: local-dev MongoDB has no auth). ButGeneralPaneViewused that same flag to decide whether the Username field is visible. Those are different questions:With the field hidden, the connection saved
username = "". The driver'sbuildUri()guards credentials behindif !user.isEmpty, so the URI had no userinfo at all.connect()only runs{"ping": 1}, which MongoDB allows unauthenticated, so the connection looked healthy. The first real operation,listCollectionsfor the table list, failed with MongoDB error code 13 (Unauthorized).Fix
Gate the Username field on
connectionMode == .networkinstead ofrequiresAuthentication.authenticationSectionis only built for non-file-based connections, so the reachable modes are.networkand.apiOnly. Every network database supports a username regardless of whether auth is enforced;.apiOnlyconnections authenticate through their ownauthFieldsand correctly keep it hidden.Main-app only. No plugin change, no PluginKit ABI bump, no registry re-tag.
Notes
Two related issues found but left out of this PR:
requiresAuthenticationmisuse. It doesn't cause this bug (MongoDB auto-discovers databases once authenticated).MongoDBConnection.buildUri()silently drops a password when the username is empty. That's a plugin-side change; once this fix lands, it's only reachable by deliberately leaving Username blank.Test plan
.apiOnlyconnections (DynamoDB, BigQuery) still hide the Username field