From 7627230be6ef967c3a559068a7855baed097f3e8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 22 Apr 2022 17:24:50 +0100 Subject: [PATCH 1/2] Fixing an issue we've experienced with couch, using a base64 cookie that we control manually. --- packages/backend-core/src/db/pouch.js | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/db/pouch.js b/packages/backend-core/src/db/pouch.js index 0e3315b43c..722913aa67 100644 --- a/packages/backend-core/src/db/pouch.js +++ b/packages/backend-core/src/db/pouch.js @@ -20,16 +20,47 @@ exports.getCouchUrl = () => { return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` } +exports.splitCouchUrl = url => { + const [protocol, rest] = url.split("://") + const [auth, host] = rest.split("@") + const [username, password] = auth.split(":") + return { + url: `${protocol}://${host}`, + auth: { + username, + password, + }, + } +} + /** * Return a constructor for PouchDB. * This should be rarely used outside of the main application config. * Exposed for exceptional cases such as in-memory views. */ exports.getPouch = (opts = {}) => { - const COUCH_DB_URL = exports.getCouchUrl() || "http://localhost:4005" + let auth = { + username: env.COUCH_DB_USERNAME, + password: env.COUCH_DB_PASSWORD, + } + let url = exports.getCouchUrl() || "http://localhost:4005" + // need to update security settings + if (!auth.username || !auth.password || url.includes("@")) { + const split = exports.splitCouchUrl(url) + url = split.url + auth = split.auth + } + const authCookie = Buffer.from(`${auth.username}:${auth.password}`).toString( + "base64" + ) let POUCH_DB_DEFAULTS = { - prefix: COUCH_DB_URL, + prefix: url, + fetch: (url, opts) => { + // use a specific authorization cookie - be very explicit about how we authenticate + opts.headers.set("Authorization", `Basic ${authCookie}`) + return PouchDB.fetch(url, opts) + }, } if (opts.inMemory) { From 81adeafd52aa9889b09a6d1e6d134bfffd8abbd7 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Sat, 23 Apr 2022 12:13:13 +0000 Subject: [PATCH 2/2] v1.0.118 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lerna.json b/lerna.json index 3274b130ff..b770c17068 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.117", + "version": "1.0.118", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index ad267bd35e..e90a0560f6 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.117", + "version": "1.0.118", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 06cd3cf0ad..8df02f1450 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.117", + "version": "1.0.118", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.0.117", + "@budibase/string-templates": "^1.0.118", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index bb1230a46b..c03c50bc2d 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.117", + "version": "1.0.118", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.117", - "@budibase/client": "^1.0.117", - "@budibase/frontend-core": "^1.0.117", - "@budibase/string-templates": "^1.0.117", + "@budibase/bbui": "^1.0.118", + "@budibase/client": "^1.0.118", + "@budibase/frontend-core": "^1.0.118", + "@budibase/string-templates": "^1.0.118", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index d5376223ec..7f3b0d2046 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.117", + "version": "1.0.118", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 24a5d1eb78..3483cb659a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.117", + "version": "1.0.118", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.117", - "@budibase/frontend-core": "^1.0.117", - "@budibase/string-templates": "^1.0.117", + "@budibase/bbui": "^1.0.118", + "@budibase/frontend-core": "^1.0.118", + "@budibase/string-templates": "^1.0.118", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 0e6571b5e7..e246d6fd2a 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.0.117", + "version": "1.0.118", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.0.117", + "@budibase/bbui": "^1.0.118", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 8638a0dafe..2cb92c82c9 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.117", + "version": "1.0.118", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -68,9 +68,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.117", - "@budibase/client": "^1.0.117", - "@budibase/string-templates": "^1.0.117", + "@budibase/backend-core": "^1.0.118", + "@budibase/client": "^1.0.118", + "@budibase/string-templates": "^1.0.118", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index a6dfd7f30a..abcca257b4 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.117", + "version": "1.0.118", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 88a0a54792..684e3dabdb 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.117", + "version": "1.0.118", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -31,8 +31,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.117", - "@budibase/string-templates": "^1.0.117", + "@budibase/backend-core": "^1.0.118", + "@budibase/string-templates": "^1.0.118", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0",