mongo.nvim icon indicating copy to clipboard operation
mongo.nvim copied to clipboard

password and username

Open FilipHarald opened this issue 3 years ago • 4 comments
trafficstars

Thank you for doing this plugin.

Is there a way to connect to a password protected instance? I have tried two ways:

1

This...

:Mongoconnect --host=<my-db-ip> --db=<my-db-name> --username=<my-username> --password=<my-password>
:Mongocollections

... gives this error...

Error executing Lua callback: Vim:E474: Unidentified byte: MongoServerError: there are no users authenticated

stack traceback:
        [C]: in function 'json_decode'
        ...arald/.local/share/nvim/plugged/mongo.nvim/lua/mongo.lua:68: in function 'get_collections'
        ...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:64: in function <...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:63>

2

This...

:Mongoconnect mongodb://${username}:${password}@${host}:${port}/${name}

...gives this error...

Error executing Lua callback: Vim:E474: Unidentified byte: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

stack traceback:
        [C]: in function 'json_decode'
        ...arald/.local/share/nvim/plugged/mongo.nvim/lua/mongo.lua:43: in function 'get_dbs'
        ...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:50: in function <...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:47>

FilipHarald avatar Nov 01 '22 09:11 FilipHarald

@FilipHarald at the moment, this plugin does not take into account auth-protected DBs, so the errors you are getting are expected. To me, this seems pretty fundamental, so support for this should be added soon. I'll be thinking about what the best way to add this would be and post back here.

jrop avatar Nov 01 '22 15:11 jrop

I'm considering changing how :Mongoconnect works: right now it is confusing and the options/combinations are not really documented well or very predictable. Just this morning, I was hung up using it for a little bit (and I wrote it!). I'm considering just changing it to pass its argument unaltered to mongosh.

The drawback is that this change would be backwards-incompatable. Thoughts? @FilipHarald

jrop avatar Dec 13 '22 18:12 jrop

OK, I'm not sure I know the implications of that security-wise. It sounds sane to have the interface as similar as possible to mongosh though.

What goes for backwards-incompatibility that is not an issue for me. @jrop

FilipHarald avatar Dec 13 '22 22:12 FilipHarald

Alternatively, it would be amazing if we could pass a connection string like: :Mongoconnect --uri mongodb+srv://username:password@host:port/db_name

petr-nazarov-yoobic avatar Nov 14 '23 15:11 petr-nazarov-yoobic