From 6b13d2ceaa30647d5180a040ae9d6d06dbae0869 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 2 Dec 2021 16:04:44 +0000 Subject: [PATCH 1/8] Removing auto columns from export - the new table will provide these if required. --- .../server/src/api/controllers/view/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/view/index.js b/packages/server/src/api/controllers/view/index.js index 3b43ef2408..b4399f416d 100644 --- a/packages/server/src/api/controllers/view/index.js +++ b/packages/server/src/api/controllers/view/index.js @@ -77,6 +77,7 @@ exports.exportView = async ctx => { } await fetchView(ctx) + let rows = ctx.body let schema = view && view.meta && view.meta.schema if (!schema) { @@ -85,11 +86,23 @@ exports.exportView = async ctx => { schema = table.schema } + // remove any auto columns + const autocolumns = Object.entries(schema) + .filter(entry => entry[1].autocolumn) + .map(entry => entry[0]) + rows.forEach(row => { + autocolumns.forEach(column => delete row[column]) + }) + // delete auto columns from schema + autocolumns.forEach(column => { + delete schema[column] + }) + // make sure no "undefined" entries appear in the CSV if (format === exporters.ExportFormats.CSV) { const schemaKeys = Object.keys(schema) for (let key of schemaKeys) { - for (let row of ctx.body) { + for (let row of rows) { if (row[key] == null) { row[key] = "" } @@ -103,5 +116,5 @@ exports.exportView = async ctx => { const filename = `${viewName}.${format}` // send down the file ctx.attachment(filename) - ctx.body = apiFileReturn(exporter(headers, ctx.body)) + ctx.body = apiFileReturn(exporter(headers, rows)) } From a6de5a4fa1f8affe5b783126d7475a0f84614d6e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 2 Dec 2021 16:17:10 +0000 Subject: [PATCH 2/8] Exporting date and auto id field, but not importing autocolumns when table is created. --- packages/server/src/api/controllers/table/utils.js | 1 + packages/server/src/api/controllers/view/index.js | 13 +++++++------ packages/server/src/utilities/csvParser.js | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.js b/packages/server/src/api/controllers/table/utils.js index 0623fc64b5..e4086e8071 100644 --- a/packages/server/src/api/controllers/table/utils.js +++ b/packages/server/src/api/controllers/table/utils.js @@ -75,6 +75,7 @@ exports.handleDataImport = async (appId, user, table, dataImport) => { if (!dataImport || !dataImport.csvString) { return table } + const db = new CouchDB(appId) // Populate the table with rows imported from CSV in a bulk update const data = await csvParser.transform({ diff --git a/packages/server/src/api/controllers/view/index.js b/packages/server/src/api/controllers/view/index.js index b4399f416d..9a844fedff 100644 --- a/packages/server/src/api/controllers/view/index.js +++ b/packages/server/src/api/controllers/view/index.js @@ -5,6 +5,7 @@ const exporters = require("./exporters") const { saveView, getView, getViews, deleteView } = require("./utils") const { fetchView } = require("../row") const { getTable } = require("../table/utils") +const { FieldTypes } = require("../../../constants") exports.fetch = async ctx => { const db = new CouchDB(ctx.appId) @@ -86,15 +87,15 @@ exports.exportView = async ctx => { schema = table.schema } - // remove any auto columns - const autocolumns = Object.entries(schema) - .filter(entry => entry[1].autocolumn) + // remove any relationships + const relationships = Object.entries(schema) + .filter(entry => entry[1].type === FieldTypes.LINK) .map(entry => entry[0]) rows.forEach(row => { - autocolumns.forEach(column => delete row[column]) + relationships.forEach(column => delete row[column]) }) - // delete auto columns from schema - autocolumns.forEach(column => { + // delete relationships from schema + relationships.forEach(column => { delete schema[column] }) diff --git a/packages/server/src/utilities/csvParser.js b/packages/server/src/utilities/csvParser.js index c548a71758..8f9b3373c9 100644 --- a/packages/server/src/utilities/csvParser.js +++ b/packages/server/src/utilities/csvParser.js @@ -102,8 +102,11 @@ async function transform({ schema, csvString, existingTable }) { schema = updateSchema({ schema, existingTable }) } - for (let key of Object.keys(schema)) { - colParser[key] = PARSERS[schema[key].type] || schema[key].type + for (let [key, field] of Object.entries(schema)) { + // don't import data to auto columns + if (!field.autocolumn) { + colParser[key] = PARSERS[field.type] || field.type + } } try { From a7e779639d3464b48a0254fba5e6be52fa159733 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 3 Dec 2021 10:31:09 +0000 Subject: [PATCH 3/8] Refactor. --- packages/server/src/api/controllers/view/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/controllers/view/index.js b/packages/server/src/api/controllers/view/index.js index 9a844fedff..e3232323bf 100644 --- a/packages/server/src/api/controllers/view/index.js +++ b/packages/server/src/api/controllers/view/index.js @@ -91,11 +91,11 @@ exports.exportView = async ctx => { const relationships = Object.entries(schema) .filter(entry => entry[1].type === FieldTypes.LINK) .map(entry => entry[0]) - rows.forEach(row => { - relationships.forEach(column => delete row[column]) - }) - // delete relationships from schema + // iterate relationship columns and remove from and row and schema relationships.forEach(column => { + rows.forEach(row => { + delete row[column] + }) delete schema[column] }) From 6118b7ba36f2ab17e3cbd16afcb285871eaba897 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Fri, 3 Dec 2021 10:48:47 +0000 Subject: [PATCH 4/8] Fix oracle password config --- packages/server/scripts/integrations/oracle/oracle.md | 2 +- packages/server/src/integrations/oracle.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/scripts/integrations/oracle/oracle.md b/packages/server/scripts/integrations/oracle/oracle.md index 912de08b65..6c2d7a9252 100644 --- a/packages/server/scripts/integrations/oracle/oracle.md +++ b/packages/server/scripts/integrations/oracle/oracle.md @@ -84,7 +84,7 @@ The `HR` schema is populated with dummy data by default in oracle for testing pu To connect to the HR schema first update the user password and unlock the account by performing ```sql ALTER USER hr ACCOUNT UNLOCK; -ALTER USER hr IDENTIFIED BY hr +ALTER USER hr IDENTIFIED BY hr; ``` You should now be able to connect to the hr schema using the credentials hr/hr diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index bf8e83350e..afaa902655 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -381,7 +381,7 @@ module OracleModule { }` const attributes: ConnectionAttributes = { user: this.config.user, - password: this.config.user, + password: this.config.password, connectString, } return oracledb.getConnection(attributes) From d9afc58401760c31203037f9a65c046ff9960c5a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 3 Dec 2021 11:17:48 +0000 Subject: [PATCH 5/8] Extending logout TTL from a day to a week. --- packages/auth/src/security/sessions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/security/sessions.js b/packages/auth/src/security/sessions.js index 93c2d0a9ca..ad21627bd9 100644 --- a/packages/auth/src/security/sessions.js +++ b/packages/auth/src/security/sessions.js @@ -1,6 +1,7 @@ const redis = require("../redis/authRedis") -const EXPIRY_SECONDS = 86400 +// a week in seconds +const EXPIRY_SECONDS = 86400 * 7 async function getSessionsForUser(userId) { const client = await redis.getSessionClient() From aecc29b4d7dff98caa0183f3f2f3596b3fcb541f Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 3 Dec 2021 11:22:44 +0000 Subject: [PATCH 6/8] v1.0.6 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 7159f433c5..73fa6bd62d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.5", + "version": "1.0.6", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 8892f232a6..d9fc21720a 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "1.0.5", + "version": "1.0.6", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 8198fed4d5..7c76c3bef6 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.5", + "version": "1.0.6", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 450478d803..d4e07d5c86 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.5", + "version": "1.0.6", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.5", - "@budibase/client": "^1.0.5", + "@budibase/bbui": "^1.0.6", + "@budibase/client": "^1.0.6", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.5", + "@budibase/string-templates": "^1.0.6", "@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 42dffc8901..299a822e4c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.5", + "version": "1.0.6", "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 8cb916e427..58e848d22a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.5", + "version": "1.0.6", "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.5", + "@budibase/bbui": "^1.0.6", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.5", + "@budibase/string-templates": "^1.0.6", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 31aabf1dad..d22669626b 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.5", + "version": "1.0.6", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -69,9 +69,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.5", - "@budibase/client": "^1.0.5", - "@budibase/string-templates": "^1.0.5", + "@budibase/auth": "^1.0.6", + "@budibase/client": "^1.0.6", + "@budibase/string-templates": "^1.0.6", "@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 e14c584e09..60c35a2a2d 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.5", + "version": "1.0.6", "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 7a112ab00e..d9d32ce35c 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.5", + "version": "1.0.6", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.5", - "@budibase/string-templates": "^1.0.5", + "@budibase/auth": "^1.0.6", + "@budibase/string-templates": "^1.0.6", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From de72792576e032b0dc6edf2f331ecbaa39a47679 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 3 Dec 2021 12:39:20 +0000 Subject: [PATCH 7/8] Setting auth cookie to not expire. --- packages/auth/src/constants.js | 1 + packages/auth/src/utils.js | 9 +++++---- .../worker/src/api/controllers/global/auth.js | 17 +---------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/auth/src/constants.js b/packages/auth/src/constants.js index 9892275bec..363274eda5 100644 --- a/packages/auth/src/constants.js +++ b/packages/auth/src/constants.js @@ -34,4 +34,5 @@ exports.Configs = { OIDC_LOGOS: "logos_oidc", } +exports.MAX_VALID_DATE = new Date(2147483647000) exports.DEFAULT_TENANT_ID = "default" diff --git a/packages/auth/src/utils.js b/packages/auth/src/utils.js index f7ab5d6990..b8fa7b9588 100644 --- a/packages/auth/src/utils.js +++ b/packages/auth/src/utils.js @@ -7,7 +7,7 @@ const { const jwt = require("jsonwebtoken") const { options } = require("./middleware/passport/jwt") const { createUserEmailView } = require("./db/views") -const { Headers, UserStatus, Cookies } = require("./constants") +const { Headers, UserStatus, Cookies, MAX_VALID_DATE } = require("./constants") const { getGlobalDB, updateTenantId, @@ -83,14 +83,15 @@ exports.getCookie = (ctx, name) => { * @param {object} ctx The request which is to be manipulated. * @param {string} name The name of the cookie to set. * @param {string|object} value The value of cookie which will be set. + * @param {object} opts options like whether to sign. */ -exports.setCookie = (ctx, value, name = "builder") => { - if (value) { +exports.setCookie = (ctx, value, name = "builder", opts = { sign: true }) => { + if (value && opts && opts.sign) { value = jwt.sign(value, options.secretOrKey) } const config = { - maxAge: Number.MAX_SAFE_INTEGER, + expires: MAX_VALID_DATE, path: "/", httpOnly: false, overwrite: true, diff --git a/packages/worker/src/api/controllers/global/auth.js b/packages/worker/src/api/controllers/global/auth.js index 592787c5ea..cd7d8abcee 100644 --- a/packages/worker/src/api/controllers/global/auth.js +++ b/packages/worker/src/api/controllers/global/auth.js @@ -56,26 +56,11 @@ async function authInternal(ctx, user, err = null, info = null) { return ctx.throw(403, info ? info : "Unauthorized") } - const expires = new Date() - expires.setDate(expires.getDate() + 1) - if (!user) { return ctx.throw(403, info ? info : "Unauthorized") } - const config = { - expires, - path: "/", - httpOnly: false, - overwrite: true, - } - - if (env.COOKIE_DOMAIN) { - config.domain = env.COOKIE_DOMAIN - } - - // just store the user ID - ctx.cookies.set(Cookies.Auth, user.token, config) + setCookie(ctx, user.token, Cookies.Auth, { sign: false }) // get rid of any app cookies on login // have to check test because this breaks cypress if (!env.isTest()) { From 2c081c65577bf179cbd67daf3ebc9158c292c31c Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 3 Dec 2021 13:24:14 +0000 Subject: [PATCH 8/8] v1.0.7 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 73fa6bd62d..49a49487d3 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.6", + "version": "1.0.7", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index d9fc21720a..a66b3c912b 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "1.0.6", + "version": "1.0.7", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7c76c3bef6..82fb9bbda6 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.6", + "version": "1.0.7", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index d4e07d5c86..e91c57415f 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.6", + "version": "1.0.7", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.6", - "@budibase/client": "^1.0.6", + "@budibase/bbui": "^1.0.7", + "@budibase/client": "^1.0.7", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.6", + "@budibase/string-templates": "^1.0.7", "@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 299a822e4c..e7ec3372a1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.6", + "version": "1.0.7", "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 58e848d22a..8656c443ce 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.6", + "version": "1.0.7", "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.6", + "@budibase/bbui": "^1.0.7", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.6", + "@budibase/string-templates": "^1.0.7", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index d22669626b..67f6de62c0 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.6", + "version": "1.0.7", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -69,9 +69,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.6", - "@budibase/client": "^1.0.6", - "@budibase/string-templates": "^1.0.6", + "@budibase/auth": "^1.0.7", + "@budibase/client": "^1.0.7", + "@budibase/string-templates": "^1.0.7", "@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 60c35a2a2d..3036bf7e9f 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.6", + "version": "1.0.7", "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 d9d32ce35c..d556d5f581 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.6", + "version": "1.0.7", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.6", - "@budibase/string-templates": "^1.0.6", + "@budibase/auth": "^1.0.7", + "@budibase/string-templates": "^1.0.7", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0",