@budibase/server 1.0.46-alpha.4 → 1.0.46-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.c21ee1fb.js → index.51efc215.js} +243 -243
- package/builder/assets/{index.243ca52c.css → index.dd9e386f.css} +1 -1
- package/builder/assets/{vendor.10e2ad1b.js → vendor.3bd2f661.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1794 -1793
- package/coverage/coverage-final.json +136 -138
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +209 -125
- package/coverage/lcov-report/api/controllers/auth.js.html +23 -11
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +12 -12
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +58 -22
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +38 -53
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.js.html +61 -28
- package/coverage/lcov-report/api/controllers/query/validation.js.html +9 -9
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +5 -5
- package/coverage/lcov-report/api/controllers/row/index.js.html +13 -13
- package/coverage/lcov-report/api/controllers/row/internal.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
- package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -26
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/table/internal.js.html +10 -10
- package/coverage/lcov-report/api/controllers/table/utils.js.html +26 -26
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +30 -24
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +26 -26
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +14 -14
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +7 -22
- package/coverage/lcov-report/api/routes/index.js.html +31 -37
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/permission.js.html +12 -12
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +12 -12
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +10 -10
- package/coverage/lcov-report/api/routes/screen.js.html +11 -11
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +12 -12
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/automations/utils.js.html +32 -32
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +36 -24
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +7 -7
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +13 -13
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +73 -73
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +6 -6
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +62 -62
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +171 -69
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +46 -73
- package/coverage/lcov-report/middleware/index.html +24 -24
- package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
- package/coverage/lcov-report/middleware/resourceId.js.html +22 -22
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/migrations/usageQuotas/index.html +1 -1
- package/coverage/lcov-report/migrations/usageQuotas/index.js.html +6 -6
- package/coverage/lcov-report/migrations/usageQuotas/syncApps.js.html +6 -6
- package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +7 -7
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +15 -15
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +23 -8
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +26 -26
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +25 -25
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +17 -17
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +39 -108
- package/coverage/lcov.info +2292 -2272
- package/dist/api/controllers/application.js +49 -20
- package/dist/api/controllers/auth.js +4 -0
- package/dist/api/controllers/datasource.js +11 -0
- package/dist/api/controllers/query/index.js +11 -3
- package/dist/api/controllers/row/utils.js +1 -2
- package/dist/api/controllers/static/index.js +9 -10
- package/dist/api/controllers/user.js +2 -0
- package/dist/api/routes/index.js +0 -2
- package/dist/constants/index.js +3 -0
- package/dist/definitions/datasource.js +1 -0
- package/dist/integrations/googlesheets.js +340 -0
- package/dist/integrations/index.js +3 -0
- package/dist/integrations/utils.js +6 -3
- package/dist/middleware/authorized.js +55 -30
- package/dist/middleware/currentapp.js +0 -9
- package/dist/package.json +8 -5
- package/dist/tests/utilities/TestConfiguration.js +10 -6
- package/dist/threads/query.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +0 -20
- package/nodemon.json +1 -1
- package/package.json +9 -6
- package/src/api/controllers/application.js +52 -24
- package/src/api/controllers/auth.js +4 -0
- package/src/api/controllers/datasource.js +12 -0
- package/src/api/controllers/query/index.js +14 -3
- package/src/api/controllers/row/utils.js +1 -4
- package/src/api/controllers/static/index.js +13 -10
- package/src/api/controllers/user.js +2 -0
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +1 -2
- package/src/constants/index.js +4 -0
- package/src/definitions/datasource.ts +3 -0
- package/src/integrations/googlesheets.ts +353 -0
- package/src/integrations/index.ts +3 -0
- package/src/integrations/utils.ts +18 -5
- package/src/middleware/authorized.js +64 -30
- package/src/middleware/currentapp.js +0 -9
- package/src/middleware/tests/authorized.spec.js +6 -4
- package/src/migrations/tests/usageQuotas/syncRows.spec.js +1 -1
- package/src/tests/utilities/TestConfiguration.js +10 -6
- package/src/threads/query.js +5 -0
- package/src/utilities/workerRequests.js +0 -23
- package/coverage/lcov-report/api/controllers/hosting.js.html +0 -146
- package/coverage/lcov-report/api/routes/hosting.js.html +0 -119
- package/dist/api/controllers/hosting.js +0 -30
- package/dist/api/routes/hosting.js +0 -11
- package/src/api/controllers/hosting.js +0 -22
- package/src/api/routes/hosting.js +0 -13
- package/src/api/routes/tests/hosting.spec.js +0 -36
|
@@ -10,6 +10,7 @@ const airtable = require("./airtable");
|
|
|
10
10
|
const mysql = require("./mysql");
|
|
11
11
|
const arangodb = require("./arangodb");
|
|
12
12
|
const rest = require("./rest");
|
|
13
|
+
const googlesheets = require("./googlesheets");
|
|
13
14
|
const { SourceNames } = require("../definitions/datasource");
|
|
14
15
|
const DEFINITIONS = {
|
|
15
16
|
[SourceNames.POSTGRES]: postgres.schema,
|
|
@@ -23,6 +24,7 @@ const DEFINITIONS = {
|
|
|
23
24
|
[SourceNames.MYSQL]: mysql.schema,
|
|
24
25
|
[SourceNames.ARANGODB]: arangodb.schema,
|
|
25
26
|
[SourceNames.REST]: rest.schema,
|
|
27
|
+
[SourceNames.GOOGLE_SHEETS]: googlesheets.schema,
|
|
26
28
|
};
|
|
27
29
|
const INTEGRATIONS = {
|
|
28
30
|
[SourceNames.POSTGRES]: postgres.integration,
|
|
@@ -36,6 +38,7 @@ const INTEGRATIONS = {
|
|
|
36
38
|
[SourceNames.MYSQL]: mysql.integration,
|
|
37
39
|
[SourceNames.ARANGODB]: arangodb.integration,
|
|
38
40
|
[SourceNames.REST]: rest.integration,
|
|
41
|
+
[SourceNames.GOOGLE_SHEETS]: googlesheets.integration,
|
|
39
42
|
};
|
|
40
43
|
// optionally add oracle integration if the oracle binary can be installed
|
|
41
44
|
if (!(process.arch === "arm64" && process.platform === "darwin")) {
|
|
@@ -153,7 +153,9 @@ exports.isIsoDateString = isIsoDateString;
|
|
|
153
153
|
* @param tableIds The IDs of the tables which currently exist.
|
|
154
154
|
*/
|
|
155
155
|
function shouldCopyRelationship(column, tableIds) {
|
|
156
|
-
return column.type === constants_1.FieldTypes.LINK &&
|
|
156
|
+
return (column.type === constants_1.FieldTypes.LINK &&
|
|
157
|
+
column.tableId &&
|
|
158
|
+
tableIds.includes(column.tableId));
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
159
161
|
* Similar function to the shouldCopyRelationship function, but instead this looks for options and boolean
|
|
@@ -164,8 +166,9 @@ function shouldCopyRelationship(column, tableIds) {
|
|
|
164
166
|
* @param fetchedColumn The fetched column to check for the type in the external database.
|
|
165
167
|
*/
|
|
166
168
|
function shouldCopySpecialColumn(column, fetchedColumn) {
|
|
167
|
-
return column.type === constants_1.FieldTypes.OPTIONS ||
|
|
168
|
-
((!fetchedColumn || fetchedColumn.type === constants_1.FieldTypes.NUMBER) &&
|
|
169
|
+
return (column.type === constants_1.FieldTypes.OPTIONS ||
|
|
170
|
+
((!fetchedColumn || fetchedColumn.type === constants_1.FieldTypes.NUMBER) &&
|
|
171
|
+
column.type === constants_1.FieldTypes.BOOLEAN));
|
|
169
172
|
}
|
|
170
173
|
/**
|
|
171
174
|
* Looks for columns which need to be copied over into the new table definitions, like relationships
|
|
@@ -12,9 +12,49 @@ const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, } = req
|
|
|
12
12
|
const { PermissionTypes, doesHaveBasePermission, } = require("@budibase/backend-core/permissions");
|
|
13
13
|
const builderMiddleware = require("./builder");
|
|
14
14
|
const { isWebhookEndpoint } = require("./utils");
|
|
15
|
+
const { buildCsrfMiddleware } = require("@budibase/backend-core/auth");
|
|
15
16
|
function hasResource(ctx) {
|
|
16
17
|
return ctx.resourceId != null;
|
|
17
18
|
}
|
|
19
|
+
const csrf = buildCsrfMiddleware();
|
|
20
|
+
/**
|
|
21
|
+
* Apply authorization to the requested resource:
|
|
22
|
+
* - If this is a builder resource the user must be a builder.
|
|
23
|
+
* - Builders can access all resources.
|
|
24
|
+
* - Otherwise the user must have the required role.
|
|
25
|
+
*/
|
|
26
|
+
const checkAuthorized = (ctx, resourceRoles, permType, permLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
// check if this is a builder api and the user is not a builder
|
|
28
|
+
const isBuilder = ctx.user && ctx.user.builder && ctx.user.builder.global;
|
|
29
|
+
const isBuilderApi = permType === PermissionTypes.BUILDER;
|
|
30
|
+
if (isBuilderApi && !isBuilder) {
|
|
31
|
+
return ctx.throw(403, "Not Authorized");
|
|
32
|
+
}
|
|
33
|
+
// check for resource authorization
|
|
34
|
+
if (!isBuilder) {
|
|
35
|
+
yield checkAuthorizedResource(ctx, resourceRoles, permType, permLevel);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const checkAuthorizedResource = (ctx, resourceRoles, permType, permLevel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
// get the user's roles
|
|
40
|
+
const roleId = ctx.roleId || BUILTIN_ROLE_IDS.PUBLIC;
|
|
41
|
+
const userRoles = yield getUserRoleHierarchy(ctx.appId, roleId, {
|
|
42
|
+
idOnly: false,
|
|
43
|
+
});
|
|
44
|
+
const permError = "User does not have permission";
|
|
45
|
+
// check if the user has the required role
|
|
46
|
+
if (resourceRoles.length > 0) {
|
|
47
|
+
// deny access if the user doesn't have the required resource role
|
|
48
|
+
const found = userRoles.find(role => resourceRoles.indexOf(role._id) !== -1);
|
|
49
|
+
if (!found) {
|
|
50
|
+
ctx.throw(403, permError);
|
|
51
|
+
}
|
|
52
|
+
// fallback to the base permissions when no resource roles are found
|
|
53
|
+
}
|
|
54
|
+
else if (!doesHaveBasePermission(permType, permLevel, userRoles)) {
|
|
55
|
+
ctx.throw(403, permError);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
18
58
|
module.exports =
|
|
19
59
|
(permType, permLevel = null) => (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
60
|
// webhooks don't need authentication, each webhook unique
|
|
@@ -28,37 +68,22 @@ module.exports =
|
|
|
28
68
|
// check general builder stuff, this middleware is a good way
|
|
29
69
|
// to find API endpoints which are builder focused
|
|
30
70
|
yield builderMiddleware(ctx, permType);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (isBuilder) {
|
|
36
|
-
return next();
|
|
37
|
-
}
|
|
38
|
-
else if (isBuilderApi && !isBuilder) {
|
|
39
|
-
return ctx.throw(403, "Not Authorized");
|
|
71
|
+
// get the resource roles
|
|
72
|
+
let resourceRoles = [];
|
|
73
|
+
if (ctx.appId && hasResource(ctx)) {
|
|
74
|
+
resourceRoles = yield getRequiredResourceRole(ctx.appId, permLevel, ctx);
|
|
40
75
|
}
|
|
41
|
-
//
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
const permError = "User does not have permission";
|
|
47
|
-
let possibleRoleIds = [];
|
|
48
|
-
if (hasResource(ctx)) {
|
|
49
|
-
possibleRoleIds = yield getRequiredResourceRole(ctx.appId, permLevel, ctx);
|
|
50
|
-
}
|
|
51
|
-
// check if we found a role, if not fallback to base permissions
|
|
52
|
-
if (possibleRoleIds.length > 0) {
|
|
53
|
-
const found = hierarchy.find(role => possibleRoleIds.indexOf(role._id) !== -1);
|
|
54
|
-
return found ? next() : ctx.throw(403, permError);
|
|
55
|
-
}
|
|
56
|
-
else if (!doesHaveBasePermission(permType, permLevel, hierarchy)) {
|
|
57
|
-
ctx.throw(403, permError);
|
|
76
|
+
// if the resource is public, proceed
|
|
77
|
+
const isPublicResource = resourceRoles.includes(BUILTIN_ROLE_IDS.PUBLIC);
|
|
78
|
+
if (isPublicResource) {
|
|
79
|
+
return next();
|
|
58
80
|
}
|
|
59
|
-
//
|
|
60
|
-
if (!
|
|
61
|
-
ctx.throw(403, "Session not authenticated");
|
|
81
|
+
// check authenticated
|
|
82
|
+
if (!ctx.isAuthenticated) {
|
|
83
|
+
return ctx.throw(403, "Session not authenticated");
|
|
62
84
|
}
|
|
63
|
-
|
|
85
|
+
// check authorized
|
|
86
|
+
yield checkAuthorized(ctx, resourceRoles, permType, permLevel);
|
|
87
|
+
// csrf protection
|
|
88
|
+
return csrf(ctx, next);
|
|
64
89
|
});
|
|
@@ -49,15 +49,6 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
49
49
|
!isWebhookEndpoint(ctx) &&
|
|
50
50
|
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)) {
|
|
51
51
|
clearCookie(ctx, Cookies.CurrentApp);
|
|
52
|
-
// have to set the return url on the server side as client side is not available
|
|
53
|
-
setCookie(ctx, ctx.url, Cookies.RETURN_URL, {
|
|
54
|
-
// don't sign so the browser can easily read
|
|
55
|
-
sign: false,
|
|
56
|
-
// use the request domain to match how ui handles the return url cookie.
|
|
57
|
-
// it's important we don't use the shared domain here as the builder
|
|
58
|
-
// can't delete from it without awareness of the domain.
|
|
59
|
-
requestDomain: true,
|
|
60
|
-
});
|
|
61
52
|
return ctx.redirect("/");
|
|
62
53
|
}
|
|
63
54
|
let appId, roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.46-alpha.
|
|
4
|
+
"version": "1.0.46-alpha.7",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.46-alpha.
|
|
74
|
-
"@budibase/client": "^1.0.46-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.46-alpha.
|
|
73
|
+
"@budibase/backend-core": "^1.0.46-alpha.7",
|
|
74
|
+
"@budibase/client": "^1.0.46-alpha.7",
|
|
75
|
+
"@budibase/string-templates": "^1.0.46-alpha.7",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -92,6 +92,8 @@
|
|
|
92
92
|
"fix-path": "3.0.0",
|
|
93
93
|
"form-data": "^4.0.0",
|
|
94
94
|
"fs-extra": "8.1.0",
|
|
95
|
+
"google-auth-library": "^7.11.0",
|
|
96
|
+
"google-spreadsheet": "^3.2.0",
|
|
95
97
|
"jimp": "0.16.1",
|
|
96
98
|
"joi": "17.2.1",
|
|
97
99
|
"js-yaml": "^4.1.0",
|
|
@@ -110,7 +112,7 @@
|
|
|
110
112
|
"mongodb": "3.6.3",
|
|
111
113
|
"mssql": "6.2.3",
|
|
112
114
|
"mysql2": "^2.3.1",
|
|
113
|
-
"node-fetch": "2.6.
|
|
115
|
+
"node-fetch": "2.6.7",
|
|
114
116
|
"open": "^8.4.0",
|
|
115
117
|
"pg": "8.5.1",
|
|
116
118
|
"pino-pretty": "4.0.0",
|
|
@@ -139,6 +141,7 @@
|
|
|
139
141
|
"@jest/test-sequencer": "^24.8.0",
|
|
140
142
|
"@types/apidoc": "^0.50.0",
|
|
141
143
|
"@types/bull": "^3.15.1",
|
|
144
|
+
"@types/google-spreadsheet": "^3.1.5",
|
|
142
145
|
"@types/jest": "^26.0.23",
|
|
143
146
|
"@types/koa": "^2.13.3",
|
|
144
147
|
"@types/koa-router": "^7.4.2",
|
|
@@ -21,9 +21,11 @@ const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
|
21
21
|
const { createASession } = require("@budibase/backend-core/sessions");
|
|
22
22
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
23
23
|
const CouchDB = require("../../db");
|
|
24
|
+
const newid = require("../../db/newid");
|
|
24
25
|
core.init(CouchDB);
|
|
25
26
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
26
27
|
const EMAIL = "babs@babs.com";
|
|
28
|
+
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
27
29
|
class TestConfiguration {
|
|
28
30
|
constructor(openServer = true) {
|
|
29
31
|
if (openServer) {
|
|
@@ -72,7 +74,11 @@ class TestConfiguration {
|
|
|
72
74
|
existing = { email };
|
|
73
75
|
}
|
|
74
76
|
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID });
|
|
75
|
-
yield createASession(id, {
|
|
77
|
+
yield createASession(id, {
|
|
78
|
+
sessionId: "sessionid",
|
|
79
|
+
tenantId: TENANT_ID,
|
|
80
|
+
csrfToken: CSRF_TOKEN,
|
|
81
|
+
});
|
|
76
82
|
if (builder) {
|
|
77
83
|
user.builder = { global: true };
|
|
78
84
|
}
|
|
@@ -83,7 +89,8 @@ class TestConfiguration {
|
|
|
83
89
|
return Object.assign({ _rev: resp._rev }, user);
|
|
84
90
|
});
|
|
85
91
|
}
|
|
86
|
-
|
|
92
|
+
// use a new id as the name to avoid name collisions
|
|
93
|
+
init(appName = newid()) {
|
|
87
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
95
|
yield this.globalUser();
|
|
89
96
|
return this.createApp(appName);
|
|
@@ -116,6 +123,7 @@ class TestConfiguration {
|
|
|
116
123
|
`${Cookies.Auth}=${authToken}`,
|
|
117
124
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
118
125
|
],
|
|
126
|
+
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
119
127
|
};
|
|
120
128
|
if (this.appId) {
|
|
121
129
|
headers[Headers.APP_ID] = this.appId;
|
|
@@ -394,10 +402,6 @@ class TestConfiguration {
|
|
|
394
402
|
roles: { [this.prodAppId]: roleId },
|
|
395
403
|
});
|
|
396
404
|
}
|
|
397
|
-
yield createASession(userId, {
|
|
398
|
-
sessionId: "sessionid",
|
|
399
|
-
tenantId: TENANT_ID,
|
|
400
|
-
});
|
|
401
405
|
// have to fake this
|
|
402
406
|
const auth = {
|
|
403
407
|
userId,
|
package/dist/threads/query.js
CHANGED
|
@@ -75,6 +75,10 @@ class QueryRunner {
|
|
|
75
75
|
yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
|
|
76
76
|
return this.execute();
|
|
77
77
|
}
|
|
78
|
+
// check for undefined response
|
|
79
|
+
if (!rows) {
|
|
80
|
+
rows = [];
|
|
81
|
+
}
|
|
78
82
|
// needs to an array for next step
|
|
79
83
|
if (!Array.isArray(rows)) {
|
|
80
84
|
rows = [rows];
|