-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connecting without the database name yields an Authentication error #22
Comments
Hey, Thank you for bringing up this issue.
I initially thought it was necessary to not specify the database in the client creation when using:
I completely agree, this is a great idea. My only concern is how we should modify the constructor parameters to avoid breaking existing code. So perhaps we can change from: I would like to know your thoughts on this, @raineorshine, if you have time. |
My understanding is that mongo allows to authentify the user with respect to a certain "authentication database" (see the "defaultauthdb" option); the user may then open one or several databases for read/write operations, which may be the same as the auth db, or not.
Love this idea, much better than mine. This way we can keep compatibility with previous versions. And it will be clearer in the documentation that exactly one of |
I resolved the issue as we discussed and released a new version on npm. so i close this issue |
I am using y-mongodb-provider in a small project in which I already have a working Mongo connection. When reusing the same exact connection string, y-mongodb-provider cannot access the database (any attempt to get or write a YDoc yields an "Authentication error").
I have been able to pinpoint this problem to the fact that y-mongodb-provider removes the database name when creating a
MongoClient
, in theMongoAdapter
(and especially itsparseMongoDBConnectionString
helper function).When commenting the
url.pathname = '/';
line, everything works perfectly fine.While I could probably solve this by adding more permissions to my mongo user (perhaps logging to the default db instead of my specific project db?), I'd rather keep the users and dbs neatly contained, each user having access to a specific db. Is there a rationale for removing the database name from the connection string?
On a related note, it would be useful to be able to give y-mongodb-provider an existing instance of
MongoClient
, instead of forcing to create a new instance (and thus a new connection to the database).I've also been able to do this, by replacing the signatures of your constructors, and putting
client
anddb
optional options inside the dictionary. When these variables are set,MongoAdapter
uses them; otherwise, we expectconnectionString
to be set, and create a new connection as before.See for example:
I can send a PR fairly quickly, but since it would be a breaking change (because of the different signature), I prefer asking first what you think of this idea.
The text was updated successfully, but these errors were encountered: