diff --git a/lib/authn.js b/lib/authn.js index 0bb4a89..6e66a7a 100644 --- a/lib/authn.js +++ b/lib/authn.js @@ -14,15 +14,24 @@ const {util: {BedrockError}} = bedrock; export async function openDatabase(options) { const config = bedrock.config.mongodb; + + let opts; + if(config.url) { + opts = { + // FIXME: temporary experiment + url: `${config.url}?authSource=admin` + }; + } else { // copy the config stuff related to connecting - const opts = { - database: config.name, - authentication: {...config.authentication}, - // authSource should be set in connectOptions - connectOptions: {...config.connectOptions}, - writeOptions: {...config.writeOptions}, - ...options - }; + opts = { + database: config.name, + authentication: {...config.authentication}, + // authSource should be set in connectOptions + connectOptions: {...config.connectOptions}, + writeOptions: {...config.writeOptions}, + ...options + }; + } // if a `url` was not specified, create one from the `config` if(!opts.url) {