digitalbazaar / bedrock-mongodb

Bedrock mongodb module
Apache License 2.0
2 stars 3 forks source link

Address admin issues #44

Closed aljones15 closed 4 years ago

aljones15 commented 4 years ago

NOTE:

this branch now sets connectOptions.auth if username and password are set.

This updates the README so that it is easier to navigate the options necessary to connect to acces-enabled mongo dbs with replica sets. There are still code changes that would make this process easier, but for the moment this should cover it:

You can also connect to access-enabled mongo servers using some small changes to the config.mongodb.connectOptions:

const {connectOptions} = bedrock.mongodb;
// this optional and only required if connecting to a replicaSet
connectOptions.replicaSet = process.env.mongo_replicaSet;
// if you use srv in your connection string you do not need to set ssl
connectOptions.ssl = true,
// this is new and should be user over username and password
connectOptions.auth = { user: process.env.mongo_user, password: process.env.mongo_password },
// this was previously call authDB
connectOptions.authSource: process.env.mongo_authdb || 'admin'

We need to update the config.js to better reflect the options that mongo 4.2 uses as username and password have been deprecated and setting them throws a warning.

@gannan08 if you want to add you url code to this PR it is 100% welcome and would be great.

mattcollier commented 4 years ago

Related to config options below, we just use config.mongodb.username and config.username.password? That is, can we just populate auth with the existing config stuff?

// this is new and should be user over username and password
connectOptions.auth = { user: process.env.mongo_user, password: process.env.mongo_password },
aljones15 commented 4 years ago

Related to config options below, we just use config.mongodb.username and config.username.password? That is, can we just populate auth with the existing config stuff?

// this is new and should be user over username and password
connectOptions.auth = { user: process.env.mongo_user, password: process.env.mongo_password },

resolved here: https://github.com/digitalbazaar/bedrock-mongodb/pull/44/commits/3ef62964e33e0b405db522a6d19925c0faf96ab1

This did cause the tests to fail in CI, but I issued another update that fixed that.