From 8e1e016c66fe9192dbf5416260b5013dfd46a003 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 17 Aug 2021 07:16:43 +0100 Subject: [PATCH] Revert "Feature/couchdb auth" --- packages/auth/src/db/utils.js | 13 +------------ packages/auth/src/environment.js | 2 -- packages/server/scripts/dev/manage.js | 2 +- .../src/api/controllers/row/internalSearch.js | 6 ++---- packages/server/src/db/client.js | 4 ---- packages/server/src/environment.js | 2 -- packages/worker/scripts/dev/manage.js | 2 +- packages/worker/src/db/index.js | 4 ---- 8 files changed, 5 insertions(+), 30 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 2ac23d02a5..1fc78f4182 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -159,17 +159,6 @@ exports.getDeployedAppID = appId => { return appId } -exports.getCouchUrl = () => { - // username and password already exist in URL - if (env.COUCH_DB_URL.includes("@")) { - return env.COUCH_DB_URL - } - - const [protocol, ...rest] = env.COUCH_DB_URL.split("://") - - return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` -} - /** * if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing * when using Pouch it will use the pouchdb-all-dbs package. @@ -179,7 +168,7 @@ exports.getAllDbs = async () => { if (env.isTest()) { return getCouch().allDbs() } - const response = await fetch(`${exports.getCouchUrl()}/_all_dbs`) + const response = await fetch(`${env.COUCH_DB_URL}/_all_dbs`) if (response.status === 200) { return response.json() } else { diff --git a/packages/auth/src/environment.js b/packages/auth/src/environment.js index e64a1c75f0..355843d02d 100644 --- a/packages/auth/src/environment.js +++ b/packages/auth/src/environment.js @@ -9,8 +9,6 @@ function isTest() { module.exports = { JWT_SECRET: process.env.JWT_SECRET, COUCH_DB_URL: process.env.COUCH_DB_URL, - COUCH_DB_USERNAME: process.env.COUCH_DB_USER, - COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, SALT_ROUNDS: process.env.SALT_ROUNDS, REDIS_URL: process.env.REDIS_URL, REDIS_PASSWORD: process.env.REDIS_PASSWORD, diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js index 7e9d7f6a07..ffd8c6b9e3 100644 --- a/packages/server/scripts/dev/manage.js +++ b/packages/server/scripts/dev/manage.js @@ -36,7 +36,7 @@ async function init() { const envFileJson = { PORT: 4001, MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://localhost:10000/db/", + COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", REDIS_URL: "localhost:6379", WORKER_URL: "http://localhost:4002", INTERNAL_API_KEY: "budibase", diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index cc35da40ec..c13091d6e8 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -1,6 +1,6 @@ const { SearchIndexes } = require("../../../db/utils") +const env = require("../../../environment") const fetch = require("node-fetch") -const { getCouchUrl } = require("@budibase/auth/db") /** * Class to build lucene query URLs. @@ -233,9 +233,7 @@ class QueryBuilder { } async run() { - const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${ - SearchIndexes.ROWS - }` + const url = `${env.COUCH_DB_URL}/${this.appId}/_design/database/_search/${SearchIndexes.ROWS}` const body = this.buildSearchBody() return await runQuery(url, body) } diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js index 9a244fee17..d50d72b18d 100644 --- a/packages/server/src/db/client.js +++ b/packages/server/src/db/client.js @@ -12,10 +12,6 @@ PouchDB.adapter("writableStream", replicationStream.adapters.writableStream) let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, - auth: { - username: env.COUCH_DB_USERNAME, - password: env.COUCH_DB_PASSWORD, - }, } if (env.isTest()) { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 45c7673851..52c680f65a 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -23,8 +23,6 @@ module.exports = { // important PORT: process.env.PORT, JWT_SECRET: process.env.JWT_SECRET, - COUCH_DB_USERNAME: process.env.COUCH_DB_USER, - COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, COUCH_DB_URL: process.env.COUCH_DB_URL, MINIO_URL: process.env.MINIO_URL, WORKER_URL: process.env.WORKER_URL, diff --git a/packages/worker/scripts/dev/manage.js b/packages/worker/scripts/dev/manage.js index d7eb76fc74..b9d28b6278 100644 --- a/packages/worker/scripts/dev/manage.js +++ b/packages/worker/scripts/dev/manage.js @@ -17,7 +17,7 @@ async function init() { REDIS_URL: "localhost:6379", REDIS_PASSWORD: "budibase", MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://localhost:10000/db/", + COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index c0676634f7..d6d035cff1 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -7,10 +7,6 @@ const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/" let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, - auth: { - username: env.COUCH_DB_USERNAME, - password: env.COUCH_DB_PASSWORD, - }, } if (env.isTest()) {