From 5e1244824b2c8d77823f6e02685ef6390acdc414 Mon Sep 17 00:00:00 2001 From: Matthew Collier Date: Tue, 12 Dec 2023 12:07:01 -0500 Subject: [PATCH] Limit ops tourl only. --- lib/authn.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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) {