@budibase/server 1.0.98 → 1.0.99
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.2dcb5072.js → index.44b5c19a.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +91 -85
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +5 -5
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +7 -7
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +16 -16
- 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 +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +75 -15
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +15 -15
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/index.js.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +175 -155
- package/dist/api/controllers/permission.js +3 -4
- package/dist/api/routes/table.js +1 -1
- package/dist/middleware/authorized.js +24 -7
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/specs/openapi.json +23 -3
- package/specs/openapi.yaml +20 -4
- package/specs/resources/query.js +27 -5
- package/src/api/controllers/permission.js +3 -3
- package/src/api/routes/table.js +1 -1
- package/src/definitions/openapi.ts +12 -2
- package/src/middleware/authorized.js +26 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.99",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"license": "GPL-3.0",
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
71
|
-
"@budibase/backend-core": "^1.0.
|
|
72
|
-
"@budibase/client": "^1.0.
|
|
73
|
-
"@budibase/string-templates": "^1.0.
|
|
71
|
+
"@budibase/backend-core": "^1.0.99",
|
|
72
|
+
"@budibase/client": "^1.0.99",
|
|
73
|
+
"@budibase/string-templates": "^1.0.99",
|
|
74
74
|
"@bull-board/api": "^3.7.0",
|
|
75
75
|
"@bull-board/koa": "^3.7.0",
|
|
76
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -171,5 +171,5 @@
|
|
|
171
171
|
"optionalDependencies": {
|
|
172
172
|
"oracledb": "^5.3.0"
|
|
173
173
|
},
|
|
174
|
-
"gitHead": "
|
|
174
|
+
"gitHead": "c5880f9ec2a22c0a04388e3cd4727a19ad14bfd7"
|
|
175
175
|
}
|
package/specs/openapi.json
CHANGED
|
@@ -1260,10 +1260,30 @@
|
|
|
1260
1260
|
]
|
|
1261
1261
|
},
|
|
1262
1262
|
"executeQuery": {
|
|
1263
|
-
"description": "The
|
|
1263
|
+
"description": "The parameters required for executing a query.",
|
|
1264
1264
|
"type": "object",
|
|
1265
|
-
"
|
|
1266
|
-
"
|
|
1265
|
+
"properties": {
|
|
1266
|
+
"parameters": {
|
|
1267
|
+
"type": "object",
|
|
1268
|
+
"description": "This contains the required parameters for the query, this depends on query type, setup and bindings.",
|
|
1269
|
+
"additionalProperties": {
|
|
1270
|
+
"description": "Key value properties of any type, depending on the query output schema."
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
"pagination": {
|
|
1274
|
+
"type": "object",
|
|
1275
|
+
"description": "For supported query types (currently on REST) pagination can be performed using these properties.",
|
|
1276
|
+
"properties": {
|
|
1277
|
+
"page": {
|
|
1278
|
+
"type": "string",
|
|
1279
|
+
"description": "The page which has been returned from a previous query."
|
|
1280
|
+
},
|
|
1281
|
+
"limit": {
|
|
1282
|
+
"type": "number",
|
|
1283
|
+
"description": "The number of rows to return per page."
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1267
1287
|
}
|
|
1268
1288
|
},
|
|
1269
1289
|
"executeQueryOutput": {
|
package/specs/openapi.yaml
CHANGED
|
@@ -951,11 +951,27 @@ components:
|
|
|
951
951
|
required:
|
|
952
952
|
- data
|
|
953
953
|
executeQuery:
|
|
954
|
-
description: The
|
|
955
|
-
this depends on query type, setup and bindings.
|
|
954
|
+
description: The parameters required for executing a query.
|
|
956
955
|
type: object
|
|
957
|
-
|
|
958
|
-
|
|
956
|
+
properties:
|
|
957
|
+
parameters:
|
|
958
|
+
type: object
|
|
959
|
+
description: This contains the required parameters for the query, this depends
|
|
960
|
+
on query type, setup and bindings.
|
|
961
|
+
additionalProperties:
|
|
962
|
+
description: Key value properties of any type, depending on the query output
|
|
963
|
+
schema.
|
|
964
|
+
pagination:
|
|
965
|
+
type: object
|
|
966
|
+
description: For supported query types (currently on REST) pagination can be
|
|
967
|
+
performed using these properties.
|
|
968
|
+
properties:
|
|
969
|
+
page:
|
|
970
|
+
type: string
|
|
971
|
+
description: The page which has been returned from a previous query.
|
|
972
|
+
limit:
|
|
973
|
+
type: number
|
|
974
|
+
description: The number of rows to return per page.
|
|
959
975
|
executeQueryOutput:
|
|
960
976
|
type: object
|
|
961
977
|
properties:
|
package/specs/resources/query.js
CHANGED
|
@@ -124,12 +124,34 @@ const querySchema = object(
|
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
const executeQuerySchema = {
|
|
127
|
-
description:
|
|
128
|
-
"The query body must contain the required parameters for the query, this depends on query type, setup and bindings.",
|
|
127
|
+
description: "The parameters required for executing a query.",
|
|
129
128
|
type: "object",
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
properties: {
|
|
130
|
+
parameters: {
|
|
131
|
+
type: "object",
|
|
132
|
+
description:
|
|
133
|
+
"This contains the required parameters for the query, this depends on query type, setup and bindings.",
|
|
134
|
+
additionalProperties: {
|
|
135
|
+
description:
|
|
136
|
+
"Key value properties of any type, depending on the query output schema.",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
pagination: {
|
|
140
|
+
type: "object",
|
|
141
|
+
description:
|
|
142
|
+
"For supported query types (currently on REST) pagination can be performed using these properties.",
|
|
143
|
+
properties: {
|
|
144
|
+
page: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description:
|
|
147
|
+
"The page which has been returned from a previous query.",
|
|
148
|
+
},
|
|
149
|
+
limit: {
|
|
150
|
+
type: "number",
|
|
151
|
+
description: "The number of rows to return per page.",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
133
155
|
},
|
|
134
156
|
}
|
|
135
157
|
|
|
@@ -4,6 +4,7 @@ const {
|
|
|
4
4
|
getDBRoleID,
|
|
5
5
|
getExternalRoleID,
|
|
6
6
|
getBuiltinRoles,
|
|
7
|
+
checkForRoleResourceArray,
|
|
7
8
|
} = require("@budibase/backend-core/roles")
|
|
8
9
|
const { getRoleParams } = require("../../db/utils")
|
|
9
10
|
const {
|
|
@@ -144,12 +145,11 @@ exports.getResourcePerms = async function (ctx) {
|
|
|
144
145
|
for (let level of SUPPORTED_LEVELS) {
|
|
145
146
|
// update the various roleIds in the resource permissions
|
|
146
147
|
for (let role of roles) {
|
|
147
|
-
const rolePerms = role.permissions
|
|
148
|
+
const rolePerms = checkForRoleResourceArray(role.permissions, resourceId)
|
|
148
149
|
if (
|
|
149
150
|
rolePerms &&
|
|
150
151
|
rolePerms[resourceId] &&
|
|
151
|
-
|
|
152
|
-
rolePerms[resourceId].indexOf(level) !== -1)
|
|
152
|
+
rolePerms[resourceId].indexOf(level) !== -1
|
|
153
153
|
) {
|
|
154
154
|
permissions[level] = getExternalRoleID(role._id)
|
|
155
155
|
}
|
package/src/api/routes/table.js
CHANGED
|
@@ -935,8 +935,18 @@ export interface components {
|
|
|
935
935
|
_id: string;
|
|
936
936
|
}[];
|
|
937
937
|
};
|
|
938
|
-
/** @description The
|
|
939
|
-
executeQuery: {
|
|
938
|
+
/** @description The parameters required for executing a query. */
|
|
939
|
+
executeQuery: {
|
|
940
|
+
/** @description This contains the required parameters for the query, this depends on query type, setup and bindings. */
|
|
941
|
+
parameters?: { [key: string]: unknown };
|
|
942
|
+
/** @description For supported query types (currently on REST) pagination can be performed using these properties. */
|
|
943
|
+
pagination?: {
|
|
944
|
+
/** @description The page which has been returned from a previous query. */
|
|
945
|
+
page?: string;
|
|
946
|
+
/** @description The number of rows to return per page. */
|
|
947
|
+
limit?: number;
|
|
948
|
+
};
|
|
949
|
+
};
|
|
940
950
|
executeQueryOutput: {
|
|
941
951
|
/** @description The data response from the query. */
|
|
942
952
|
data: { [key: string]: unknown }[];
|
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
} = require("@budibase/backend-core/roles")
|
|
6
6
|
const {
|
|
7
7
|
PermissionTypes,
|
|
8
|
+
PermissionLevels,
|
|
8
9
|
doesHaveBasePermission,
|
|
9
10
|
} = require("@budibase/backend-core/permissions")
|
|
10
11
|
const builderMiddleware = require("./builder")
|
|
@@ -64,7 +65,7 @@ const checkAuthorizedResource = async (
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
module.exports =
|
|
67
|
-
(permType, permLevel = null) =>
|
|
68
|
+
(permType, permLevel = null, opts = { schema: false }) =>
|
|
68
69
|
async (ctx, next) => {
|
|
69
70
|
// webhooks don't need authentication, each webhook unique
|
|
70
71
|
// also internal requests (between services) don't need authorized
|
|
@@ -81,15 +82,25 @@ module.exports =
|
|
|
81
82
|
await builderMiddleware(ctx, permType)
|
|
82
83
|
|
|
83
84
|
// get the resource roles
|
|
84
|
-
let resourceRoles = []
|
|
85
|
+
let resourceRoles = [],
|
|
86
|
+
otherLevelRoles
|
|
87
|
+
const otherLevel =
|
|
88
|
+
permLevel === PermissionLevels.READ
|
|
89
|
+
? PermissionLevels.WRITE
|
|
90
|
+
: PermissionLevels.READ
|
|
85
91
|
const appId = getAppId()
|
|
86
92
|
if (appId && hasResource(ctx)) {
|
|
87
93
|
resourceRoles = await getRequiredResourceRole(permLevel, ctx)
|
|
94
|
+
if (opts && opts.schema) {
|
|
95
|
+
otherLevelRoles = await getRequiredResourceRole(otherLevel, ctx)
|
|
96
|
+
}
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
// if the resource is public, proceed
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
if (
|
|
101
|
+
resourceRoles.includes(BUILTIN_ROLE_IDS.PUBLIC) ||
|
|
102
|
+
(otherLevelRoles && otherLevelRoles.includes(BUILTIN_ROLE_IDS.PUBLIC))
|
|
103
|
+
) {
|
|
93
104
|
return next()
|
|
94
105
|
}
|
|
95
106
|
|
|
@@ -98,8 +109,17 @@ module.exports =
|
|
|
98
109
|
return ctx.throw(403, "Session not authenticated")
|
|
99
110
|
}
|
|
100
111
|
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
try {
|
|
113
|
+
// check authorized
|
|
114
|
+
await checkAuthorized(ctx, resourceRoles, permType, permLevel)
|
|
115
|
+
} catch (err) {
|
|
116
|
+
// this is a schema, check if
|
|
117
|
+
if (opts && opts.schema && permLevel) {
|
|
118
|
+
await checkAuthorized(ctx, otherLevelRoles, permType, otherLevel)
|
|
119
|
+
} else {
|
|
120
|
+
throw err
|
|
121
|
+
}
|
|
122
|
+
}
|
|
103
123
|
|
|
104
124
|
// csrf protection
|
|
105
125
|
return csrf(ctx, next)
|