From 3a7a964ac80acb4b78ef73877bebefaf0361e4d1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 28 Mar 2022 12:03:44 +0100 Subject: [PATCH 1/8] fix launch.json --- .vscode/launch.json | 11 +++++- .../middleware/passport/datasource/google.js | 37 ++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 34951b6310..8cb49d5825 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,9 +22,16 @@ "name": "Budibase Worker", "type": "node", "request": "launch", - "program": "${workspaceFolder}/packages/worker/src/index.js", + "runtimeArgs": [ + "--nolazy", + "-r", + "ts-node/register/transpile-only" + ], + "args": [ + "${workspaceFolder}/packages/worker/src/index.ts" + ], "cwd": "${workspaceFolder}/packages/worker" - } + }, ], "compounds": [ { diff --git a/packages/backend-core/src/middleware/passport/datasource/google.js b/packages/backend-core/src/middleware/passport/datasource/google.js index c7553cee50..62d626a30c 100644 --- a/packages/backend-core/src/middleware/passport/datasource/google.js +++ b/packages/backend-core/src/middleware/passport/datasource/google.js @@ -1,15 +1,37 @@ const google = require("../google") -const { Cookies } = require("../../../constants") +const { Cookies, Configs } = require("../../../constants") const { clearCookie, getCookie } = require("../../../utils") const { getDB } = require("../../../db") +const { getScopedConfig } = require("../../../db/utils") const environment = require("../../../environment") +const { getGlobalDB } = require("../../../tenancy") + +async function fetchGoogleCreds() { + let config + + // try and get the config from the tenant + const db = getGlobalDB() + const googleConfig = await getScopedConfig(db, { + type: Configs.GOOGLE, + }) + if (googleConfig.clientID && googleConfig.clientSecret) { + config = googleConfig + } + + // fall back to env variables + if (!config) { + config = { + clientID: environment.GOOGLE_CLIENT_ID, + clientSecret: environment.GOOGLE_CLIENT_SECRET, + } + } + + return googleConfig +} async function preAuth(passport, ctx, next) { // get the relevant config - const googleConfig = { - clientID: environment.GOOGLE_CLIENT_ID, - clientSecret: environment.GOOGLE_CLIENT_SECRET, - } + const googleConfig = await fetchGoogleCreds() let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback` const strategy = await google.strategyFactory(googleConfig, callbackUrl) @@ -26,10 +48,7 @@ async function preAuth(passport, ctx, next) { async function postAuth(passport, ctx, next) { // get the relevant config - const config = { - clientID: environment.GOOGLE_CLIENT_ID, - clientSecret: environment.GOOGLE_CLIENT_SECRET, - } + const config = await fetchGoogleCreds() let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback` const strategy = await google.strategyFactory( From e109f06fb4ed04feb2b077e06f475d902fb7bd21 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 28 Mar 2022 16:26:37 +0100 Subject: [PATCH 2/8] Fix automation section crashing when a table has been deleted and is in use --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index a94a78286c..3d857ec9fb 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -162,7 +162,7 @@