diff --git a/lerna.json b/lerna.json index d367f92fc4..11a729658b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.185", + "version": "1.0.187", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index d22a79e41d..1ec80ae7b2 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.185", + "version": "1.0.187", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 10bd3cb85a..b702529dc4 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -999,11 +999,6 @@ bcrypt@^5.0.1: "@mapbox/node-pre-gyp" "^1.0.0" node-addon-api "^3.1.0" -bcryptjs@^2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" - integrity sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ== - bl@^4.0.3: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" diff --git a/packages/bbui/package.json b/packages/bbui/package.json index a0364e04ca..e4cd099e6e 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.185", + "version": "1.0.187", "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.185", + "@budibase/string-templates": "^1.0.187", "@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 0ddf951ea9..51891e15f2 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.185", + "version": "1.0.187", "license": "GPL-3.0", "private": true, "scripts": { @@ -67,10 +67,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.185", - "@budibase/client": "^1.0.185", - "@budibase/frontend-core": "^1.0.185", - "@budibase/string-templates": "^1.0.185", + "@budibase/bbui": "^1.0.187", + "@budibase/client": "^1.0.187", + "@budibase/frontend-core": "^1.0.187", + "@budibase/string-templates": "^1.0.187", "@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 558b0fa870..723b4d2b35 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.185", + "version": "1.0.187", "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 1838dc1b9e..efab1c77ee 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.185", + "version": "1.0.187", "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.185", - "@budibase/frontend-core": "^1.0.185", - "@budibase/string-templates": "^1.0.185", + "@budibase/bbui": "^1.0.187", + "@budibase/frontend-core": "^1.0.187", + "@budibase/string-templates": "^1.0.187", "@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 9ac0200f3e..f6be6519a5 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.0.185", + "version": "1.0.187", "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.185", + "@budibase/bbui": "^1.0.187", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index f26f26e44d..e24f632f96 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.185", + "version": "1.0.187", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,10 +70,10 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.185", - "@budibase/client": "^1.0.185", - "@budibase/pro": "1.0.185", - "@budibase/string-templates": "^1.0.185", + "@budibase/backend-core": "^1.0.187", + "@budibase/client": "^1.0.187", + "@budibase/pro": "1.0.187", + "@budibase/string-templates": "^1.0.187", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 6bf85ba657..3acf2400d6 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1014,10 +1014,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.185": - version "1.0.185" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.185.tgz#a8b71e4234ac21f3b5c8cbcae0c63b481039d4b3" - integrity sha512-Q6MelbxX7UP21lAe7HFb9uUczPaydN6gqq1s8R985A1Yatx2K8gV7vxQo3BD9eGhSb464V9WBasWJT9If96kqA== +"@budibase/backend-core@1.0.187": + version "1.0.187" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.187.tgz#bf2d6de627185e5388d567762491334bc1d2d546" + integrity sha512-C9FqOf+/SNNWk7bZU7PfnzDvXM5ntnZFgpX1bI/bfHH3xYGw6jOFB2BpoTaV2sQGq14wfmo9e9vNHqYIT9tPrg== dependencies: "@techpass/passport-openidconnect" "^0.3.0" aws-sdk "^2.901.0" @@ -1091,12 +1091,12 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.0.185": - version "1.0.185" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.185.tgz#535ab62117d27fbae8480a702b99dd1b3876ebbc" - integrity sha512-G6+BjdJ2tcars6f0o1BVXEIeL4gmcU0lXhrFoMLUG4z73RzsvMy+W1kRMi+g7D/Se9CtZ6kV5pKNjlRj6A/qvg== +"@budibase/pro@1.0.187": + version "1.0.187" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.187.tgz#40ed5e9809f924e5d0c7bbb7d09a602ea47dfe92" + integrity sha512-whEcWAcgkIL4EHgh08jp8itR37LZYlZxFLl0GYY5AOIguEScJ1FRe9WcYFNW0Pw768uaq7IE7hKkrAzWetzu4g== dependencies: - "@budibase/backend-core" "1.0.185" + "@budibase/backend-core" "1.0.187" node-fetch "^2.6.1" "@budibase/standard-components@^0.9.139": diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index ace32929db..5cc329ee7b 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.185", + "version": "1.0.187", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/docker_run.sh b/packages/worker/docker_run.sh index bd0d3e50aa..e80f3e1658 100755 --- a/packages/worker/docker_run.sh +++ b/packages/worker/docker_run.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh if [[ -z $CLUSTER_MODE ]]; then yarn run:docker diff --git a/packages/worker/package.json b/packages/worker/package.json index a95a779f4e..8f5cbd9265 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.185", + "version": "1.0.187", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -32,9 +32,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.185", - "@budibase/pro": "1.0.185", - "@budibase/string-templates": "^1.0.185", + "@budibase/backend-core": "^1.0.187", + "@budibase/pro": "1.0.187", + "@budibase/string-templates": "^1.0.187", "@koa/router": "^8.0.0", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "^0.3.0", diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts index 11cf03d0cc..688d8c36f1 100644 --- a/packages/worker/src/api/controllers/global/users.ts +++ b/packages/worker/src/api/controllers/global/users.ts @@ -12,6 +12,7 @@ const { getTenantId, getTenantUser, doesTenantExist, + doInTenant, } = require("@budibase/backend-core/tenancy") const { removeUserFromInfoDB } = require("@budibase/backend-core/deprovision") const { errors } = require("@budibase/backend-core") @@ -41,70 +42,73 @@ const parseBooleanParam = (param: any) => { export const adminUser = async (ctx: any) => { const { email, password, tenantId } = ctx.request.body + await doInTenant(tenantId, async () => { + // account portal sends a pre-hashed password - honour param to prevent double hashing + const hashPassword = parseBooleanParam(ctx.request.query.hashPassword) + // account portal sends no password for SSO users + const requirePassword = parseBooleanParam(ctx.request.query.requirePassword) - // account portal sends a pre-hashed password - honour param to prevent double hashing - const hashPassword = parseBooleanParam(ctx.request.query.hashPassword) - // account portal sends no password for SSO users - const requirePassword = parseBooleanParam(ctx.request.query.requirePassword) - - if (await doesTenantExist(tenantId)) { - ctx.throw(403, "Organisation already exists.") - } - - const response = await doWithGlobalDB(tenantId, async (db: any) => { - const response = await db.allDocs( - getGlobalUserParams(null, { - include_docs: true, - }) - ) - // write usage quotas for cloud - if (!env.SELF_HOSTED) { - // could be a scenario where it exists, make sure its clean - try { - const usageQuota = await db.get(StaticDatabases.GLOBAL.docs.usageQuota) - if (usageQuota) { - await db.remove(usageQuota._id, usageQuota._rev) - } - } catch (err) { - // don't worry about errors - } - await db.put(quotas.generateNewQuotaUsage()) + if (await doesTenantExist(tenantId)) { + ctx.throw(403, "Organisation already exists.") } - return response - }) - if (response.rows.some((row: any) => row.doc.admin)) { - ctx.throw( - 403, - "You cannot initialise once an global user has been created." - ) - } + const response = await doWithGlobalDB(tenantId, async (db: any) => { + const response = await db.allDocs( + getGlobalUserParams(null, { + include_docs: true, + }) + ) + // write usage quotas for cloud + if (!env.SELF_HOSTED) { + // could be a scenario where it exists, make sure its clean + try { + const usageQuota = await db.get( + StaticDatabases.GLOBAL.docs.usageQuota + ) + if (usageQuota) { + await db.remove(usageQuota._id, usageQuota._rev) + } + } catch (err) { + // don't worry about errors + } + await db.put(quotas.generateNewQuotaUsage()) + } + return response + }) - const user = { - email: email, - password: password, - createdAt: Date.now(), - roles: {}, - builder: { - global: true, - }, - admin: { - global: true, - }, - tenantId, - } - try { - const finalUser = await users.save( - user, + if (response.rows.some((row: any) => row.doc.admin)) { + ctx.throw( + 403, + "You cannot initialise once an global user has been created." + ) + } + + const user = { + email: email, + password: password, + createdAt: Date.now(), + roles: {}, + builder: { + global: true, + }, + admin: { + global: true, + }, tenantId, - hashPassword, - requirePassword - ) - await bustCache(CacheKeys.CHECKLIST) - ctx.body = finalUser - } catch (err: any) { - ctx.throw(err.status || 400, err) - } + } + try { + const finalUser = await users.save( + user, + tenantId, + hashPassword, + requirePassword + ) + await bustCache(CacheKeys.CHECKLIST) + ctx.body = finalUser + } catch (err: any) { + ctx.throw(err.status || 400, err) + } + }) } export const destroy = async (ctx: any) => { diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index ff5d1e557e..679b7093af 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -293,10 +293,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.185": - version "1.0.185" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.185.tgz#a8b71e4234ac21f3b5c8cbcae0c63b481039d4b3" - integrity sha512-Q6MelbxX7UP21lAe7HFb9uUczPaydN6gqq1s8R985A1Yatx2K8gV7vxQo3BD9eGhSb464V9WBasWJT9If96kqA== +"@budibase/backend-core@1.0.187": + version "1.0.187" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.187.tgz#bf2d6de627185e5388d567762491334bc1d2d546" + integrity sha512-C9FqOf+/SNNWk7bZU7PfnzDvXM5ntnZFgpX1bI/bfHH3xYGw6jOFB2BpoTaV2sQGq14wfmo9e9vNHqYIT9tPrg== dependencies: "@techpass/passport-openidconnect" "^0.3.0" aws-sdk "^2.901.0" @@ -321,12 +321,12 @@ uuid "^8.3.2" zlib "^1.0.5" -"@budibase/pro@1.0.185": - version "1.0.185" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.185.tgz#535ab62117d27fbae8480a702b99dd1b3876ebbc" - integrity sha512-G6+BjdJ2tcars6f0o1BVXEIeL4gmcU0lXhrFoMLUG4z73RzsvMy+W1kRMi+g7D/Se9CtZ6kV5pKNjlRj6A/qvg== +"@budibase/pro@1.0.187": + version "1.0.187" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.187.tgz#40ed5e9809f924e5d0c7bbb7d09a602ea47dfe92" + integrity sha512-whEcWAcgkIL4EHgh08jp8itR37LZYlZxFLl0GYY5AOIguEScJ1FRe9WcYFNW0Pw768uaq7IE7hKkrAzWetzu4g== dependencies: - "@budibase/backend-core" "1.0.185" + "@budibase/backend-core" "1.0.187" node-fetch "^2.6.1" "@cspotcode/source-map-consumer@0.8.0":