@budibase/server 1.0.46-alpha.7 → 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.
Files changed (186) hide show
  1. package/builder/assets/{index.af9e71d8.js → index.51efc215.js} +26 -26
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +85 -75
  4. package/coverage/coverage-final.json +3 -3
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/application.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +18 -6
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +16 -16
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/user.js.html +12 -6
  40. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  46. package/coverage/lcov-report/api/index.html +1 -1
  47. package/coverage/lcov-report/api/index.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/index.html +1 -1
  60. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  77. package/coverage/lcov-report/automations/actions.js.html +1 -1
  78. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  79. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  80. package/coverage/lcov-report/automations/index.html +1 -1
  81. package/coverage/lcov-report/automations/index.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/index.html +1 -1
  91. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  108. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  109. package/coverage/lcov-report/automations/utils.js.html +1 -1
  110. package/coverage/lcov-report/constants/index.html +1 -1
  111. package/coverage/lcov-report/constants/index.js.html +1 -1
  112. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  113. package/coverage/lcov-report/constants/screens.js.html +1 -1
  114. package/coverage/lcov-report/db/client.js.html +1 -1
  115. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  116. package/coverage/lcov-report/db/index.html +1 -1
  117. package/coverage/lcov-report/db/index.js.html +1 -1
  118. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  119. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  120. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  121. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  122. package/coverage/lcov-report/db/newid.js.html +1 -1
  123. package/coverage/lcov-report/db/utils.js.html +1 -1
  124. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  125. package/coverage/lcov-report/events/index.html +1 -1
  126. package/coverage/lcov-report/events/index.js.html +1 -1
  127. package/coverage/lcov-report/events/utils.js.html +1 -1
  128. package/coverage/lcov-report/index.html +25 -25
  129. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  130. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  131. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  132. package/coverage/lcov-report/middleware/authorized.js.html +165 -63
  133. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  134. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  135. package/coverage/lcov-report/middleware/index.html +19 -19
  136. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  137. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  138. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  139. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  140. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  141. package/coverage/lcov-report/migrations/usageQuotas/index.html +1 -1
  142. package/coverage/lcov-report/migrations/usageQuotas/index.js.html +1 -1
  143. package/coverage/lcov-report/migrations/usageQuotas/syncApps.js.html +1 -1
  144. package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +1 -1
  145. package/coverage/lcov-report/threads/automation.js.html +1 -1
  146. package/coverage/lcov-report/threads/index.html +1 -1
  147. package/coverage/lcov-report/threads/index.js.html +1 -1
  148. package/coverage/lcov-report/threads/query.js.html +1 -1
  149. package/coverage/lcov-report/threads/utils.js.html +1 -1
  150. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  151. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  152. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  153. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  154. package/coverage/lcov-report/utilities/global.js.html +1 -1
  155. package/coverage/lcov-report/utilities/index.html +1 -1
  156. package/coverage/lcov-report/utilities/index.js.html +1 -1
  157. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  158. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  159. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  160. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  161. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  162. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  163. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  164. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  165. package/coverage/lcov-report/utilities/security.js.html +1 -1
  166. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  167. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  168. package/coverage/lcov-report/utilities/usageQuota/index.js.html +1 -1
  169. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  170. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  171. package/coverage/lcov-report/utilities/users.js.html +1 -1
  172. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  173. package/coverage/lcov.info +141 -123
  174. package/dist/api/controllers/auth.js +4 -0
  175. package/dist/api/controllers/user.js +2 -0
  176. package/dist/middleware/authorized.js +55 -30
  177. package/dist/package.json +4 -4
  178. package/dist/tests/utilities/TestConfiguration.js +7 -5
  179. package/dist/tsconfig.tsbuildinfo +1 -1
  180. package/package.json +5 -5
  181. package/src/api/controllers/auth.js +4 -0
  182. package/src/api/controllers/user.js +2 -0
  183. package/src/api/routes/tests/auth.spec.js +1 -2
  184. package/src/middleware/authorized.js +64 -30
  185. package/src/middleware/tests/authorized.spec.js +6 -4
  186. package/src/tests/utilities/TestConfiguration.js +7 -5
@@ -245,7 +245,7 @@
245
245
  <div class='footer quiet pad2 space-top1 center small'>
246
246
  Code coverage generated by
247
247
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
248
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
248
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
249
249
  </div>
250
250
  </div>
251
251
  <script src="../prettify.js"></script>
@@ -553,7 +553,7 @@ exports.formatBytes = bytes =&gt; {
553
553
  <div class='footer quiet pad2 space-top1 center small'>
554
554
  Code coverage generated by
555
555
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
556
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
556
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
557
557
  </div>
558
558
  </div>
559
559
  <script src="../prettify.js"></script>
@@ -367,7 +367,7 @@ module.exports = InMemoryQueue
367
367
  <div class='footer quiet pad2 space-top1 center small'>
368
368
  Code coverage generated by
369
369
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
370
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
370
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
371
371
  </div>
372
372
  </div>
373
373
  <script src="../../prettify.js"></script>
@@ -95,7 +95,7 @@
95
95
  <div class='footer quiet pad2 space-top1 center small'>
96
96
  Code coverage generated by
97
97
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
98
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
98
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
99
99
  </div>
100
100
  </div>
101
101
  <script src="../../prettify.js"></script>
@@ -95,7 +95,7 @@
95
95
  <div class='footer quiet pad2 space-top1 center small'>
96
96
  Code coverage generated by
97
97
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
98
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
98
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
99
99
  </div>
100
100
  </div>
101
101
  <script src="../../prettify.js"></script>
@@ -139,7 +139,7 @@ exports.createRoutingView = createRoutingView
139
139
  <div class='footer quiet pad2 space-top1 center small'>
140
140
  Code coverage generated by
141
141
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
142
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
142
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
143
143
  </div>
144
144
  </div>
145
145
  <script src="../../prettify.js"></script>
@@ -110,7 +110,7 @@
110
110
  <div class='footer quiet pad2 space-top1 center small'>
111
111
  Code coverage generated by
112
112
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
113
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
113
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
114
114
  </div>
115
115
  </div>
116
116
  <script src="../../prettify.js"></script>
@@ -1087,7 +1087,7 @@ exports.cleanupAttachments = async (appId, table, { row, rows, oldRow }) =&gt; {
1087
1087
  <div class='footer quiet pad2 space-top1 center small'>
1088
1088
  Code coverage generated by
1089
1089
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
1090
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
1090
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
1091
1091
  </div>
1092
1092
  </div>
1093
1093
  <script src="../../prettify.js"></script>
@@ -133,7 +133,7 @@ exports.processFormulas = (table, rows) =&gt; {
133
133
  <div class='footer quiet pad2 space-top1 center small'>
134
134
  Code coverage generated by
135
135
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
136
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
136
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
137
137
  </div>
138
138
  </div>
139
139
  <script src="../../prettify.js"></script>
@@ -136,7 +136,7 @@ module.exports = ScriptRunner
136
136
  <div class='footer quiet pad2 space-top1 center small'>
137
137
  Code coverage generated by
138
138
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
139
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
139
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
140
140
  </div>
141
141
  </div>
142
142
  <script src="../prettify.js"></script>
@@ -274,7 +274,7 @@ exports.CURRENTLY_SUPPORTED_LEVELS = CURRENTLY_SUPPORTED_LEVELS
274
274
  <div class='footer quiet pad2 space-top1 center small'>
275
275
  Code coverage generated by
276
276
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
277
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
277
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
278
278
  </div>
279
279
  </div>
280
280
  <script src="../prettify.js"></script>
@@ -85,7 +85,7 @@
85
85
  <div class='footer quiet pad2 space-top1 center small'>
86
86
  Code coverage generated by
87
87
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
88
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
88
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
89
89
  </div>
90
90
  </div>
91
91
  <script src="../prettify.js"></script>
@@ -125,7 +125,7 @@
125
125
  <div class='footer quiet pad2 space-top1 center small'>
126
126
  Code coverage generated by
127
127
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
128
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
128
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
129
129
  </div>
130
130
  </div>
131
131
  <script src="../../prettify.js"></script>
@@ -340,7 +340,7 @@ exports.update = async (property, usage, opts = { dryRun: false }) =&gt; {
340
340
  <div class='footer quiet pad2 space-top1 center small'>
341
341
  Code coverage generated by
342
342
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
343
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
343
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
344
344
  </div>
345
345
  </div>
346
346
  <script src="../../prettify.js"></script>
@@ -286,7 +286,7 @@ exports.getUniqueRows = async appIds =&gt; {
286
286
  <div class='footer quiet pad2 space-top1 center small'>
287
287
  Code coverage generated by
288
288
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
289
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
289
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
290
290
  </div>
291
291
  </div>
292
292
  <script src="../../prettify.js"></script>
@@ -118,7 +118,7 @@ function <span class="fstat-no" title="function not covered" >resetQuotasIfRequi
118
118
  <div class='footer quiet pad2 space-top1 center small'>
119
119
  Code coverage generated by
120
120
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
121
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
121
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
122
122
  </div>
123
123
  </div>
124
124
  <script src="../../prettify.js"></script>
@@ -136,7 +136,7 @@ exports.getFullUser = async (ctx, userId) =&gt; {
136
136
  <div class='footer quiet pad2 space-top1 center small'>
137
137
  Code coverage generated by
138
138
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
139
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
139
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
140
140
  </div>
141
141
  </div>
142
142
  <script src="../prettify.js"></script>
@@ -334,7 +334,7 @@ exports.removeAppFromUserRoles = async (ctx, appId) =&gt; {
334
334
  <div class='footer quiet pad2 space-top1 center small'>
335
335
  Code coverage generated by
336
336
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
337
- at Fri Jan 28 2022 15:12:12 GMT+0000 (Coordinated Universal Time)
337
+ at Sun Jan 30 2022 21:42:59 GMT+0000 (Coordinated Universal Time)
338
338
  </div>
339
339
  </div>
340
340
  <script src="../prettify.js"></script>
@@ -489,32 +489,34 @@ DA:9,1
489
489
  DA:16,1
490
490
  DA:18,1
491
491
  DA:20,1
492
- DA:21,1
492
+ DA:22,1
493
493
  DA:23,1
494
- DA:24,1
495
494
  DA:25,1
496
495
  DA:26,1
497
- DA:28,0
498
- DA:35,1
499
- DA:36,0
496
+ DA:27,1
497
+ DA:28,1
498
+ DA:30,0
499
+ DA:32,0
500
500
  DA:39,1
501
- DA:40,1
501
+ DA:40,0
502
+ DA:43,1
502
503
  DA:44,1
503
- DA:45,1
504
- DA:46,1
505
- DA:48,0
504
+ DA:48,1
505
+ DA:49,1
506
506
  DA:50,1
507
- DA:53,0
508
- LF:27
509
- LH:23
507
+ DA:52,0
508
+ DA:54,1
509
+ DA:57,0
510
+ LF:29
511
+ LH:24
510
512
  BRDA:9,0,0,1
511
513
  BRDA:9,0,1,0
512
- BRDA:20,1,0,1
513
- BRDA:20,1,1,0
514
- BRDA:35,2,0,0
515
- BRDA:35,2,1,1
516
- BRDA:39,3,0,1
517
- BRDA:39,3,1,0
514
+ BRDA:22,1,0,1
515
+ BRDA:22,1,1,0
516
+ BRDA:39,2,0,0
517
+ BRDA:39,2,1,1
518
+ BRDA:43,3,0,1
519
+ BRDA:43,3,1,0
518
520
  BRF:8
519
521
  BRH:4
520
522
  end_of_record
@@ -1728,11 +1730,11 @@ FN:101,(anonymous_7)
1728
1730
  FN:145,(anonymous_8)
1729
1731
  FN:152,(anonymous_9)
1730
1732
  FN:165,(anonymous_10)
1731
- FN:173,(anonymous_11)
1732
- FN:186,(anonymous_12)
1733
- FN:199,(anonymous_13)
1734
- FN:203,(anonymous_14)
1735
- FN:222,(anonymous_15)
1733
+ FN:175,(anonymous_11)
1734
+ FN:188,(anonymous_12)
1735
+ FN:201,(anonymous_13)
1736
+ FN:205,(anonymous_14)
1737
+ FN:224,(anonymous_15)
1736
1738
  FNF:16
1737
1739
  FNH:5
1738
1740
  FNDA:2,rawMetadata
@@ -1833,44 +1835,45 @@ DA:162,2
1833
1835
  DA:165,37
1834
1836
  DA:167,0
1835
1837
  DA:169,0
1836
- DA:170,0
1837
- DA:173,37
1838
- DA:174,1
1839
- DA:175,1
1838
+ DA:171,0
1839
+ DA:172,0
1840
+ DA:175,37
1840
1841
  DA:176,1
1842
+ DA:177,1
1841
1843
  DA:178,1
1842
- DA:179,1
1843
- DA:183,1
1844
- DA:186,37
1845
- DA:187,1
1846
- DA:188,1
1844
+ DA:180,1
1845
+ DA:181,1
1846
+ DA:185,1
1847
+ DA:188,37
1847
1848
  DA:189,1
1848
- DA:190,0
1849
- DA:194,1
1850
- DA:199,37
1851
- DA:200,1
1852
- DA:203,37
1853
- DA:204,0
1854
- DA:205,0
1849
+ DA:190,1
1850
+ DA:191,1
1851
+ DA:192,0
1852
+ DA:196,1
1853
+ DA:201,37
1854
+ DA:202,1
1855
+ DA:205,37
1855
1856
  DA:206,0
1856
1857
  DA:207,0
1858
+ DA:208,0
1857
1859
  DA:209,0
1858
- DA:210,0
1860
+ DA:211,0
1859
1861
  DA:212,0
1860
- DA:213,0
1862
+ DA:214,0
1861
1863
  DA:215,0
1862
1864
  DA:217,0
1863
- DA:218,0
1864
1865
  DA:219,0
1865
- DA:222,37
1866
- DA:223,0
1867
- DA:224,0
1866
+ DA:220,0
1867
+ DA:221,0
1868
+ DA:224,37
1868
1869
  DA:225,0
1870
+ DA:226,0
1869
1871
  DA:227,0
1870
- DA:228,0
1872
+ DA:229,0
1871
1873
  DA:230,0
1872
1874
  DA:232,0
1873
- LF:119
1875
+ DA:234,0
1876
+ LF:120
1874
1877
  LH:39
1875
1878
  BRDA:31,0,0,0
1876
1879
  BRDA:31,0,1,0
@@ -1905,10 +1908,10 @@ BRDA:127,14,0,0
1905
1908
  BRDA:127,14,1,0
1906
1909
  BRDA:135,15,0,0
1907
1910
  BRDA:135,15,1,0
1908
- BRDA:206,16,0,0
1909
- BRDA:206,16,1,0
1910
- BRDA:217,17,0,0
1911
- BRDA:217,17,1,0
1911
+ BRDA:208,16,0,0
1912
+ BRDA:208,16,1,0
1913
+ BRDA:219,17,0,0
1914
+ BRDA:219,17,1,0
1912
1915
  BRF:37
1913
1916
  BRH:0
1914
1917
  end_of_record
@@ -7086,82 +7089,97 @@ BRH:6
7086
7089
  end_of_record
7087
7090
  TN:
7088
7091
  SF:src/middleware/authorized.js
7089
- FN:13,hasResource
7090
- FN:18,(anonymous_1)
7091
- FN:19,(anonymous_2)
7092
- FN:57,(anonymous_3)
7093
- FNF:4
7094
- FNH:4
7095
- FNDA:7,hasResource
7096
- FNDA:2338,(anonymous_1)
7097
- FNDA:162,(anonymous_2)
7098
- FNDA:1,(anonymous_3)
7092
+ FN:14,hasResource
7093
+ FN:26,(anonymous_1)
7094
+ FN:40,(anonymous_2)
7095
+ FN:55,(anonymous_3)
7096
+ FN:66,(anonymous_4)
7097
+ FN:67,(anonymous_5)
7098
+ FNF:6
7099
+ FNH:5
7100
+ FNDA:155,hasResource
7101
+ FNDA:129,(anonymous_1)
7102
+ FNDA:3,(anonymous_2)
7103
+ FNDA:0,(anonymous_3)
7104
+ FNDA:2338,(anonymous_4)
7105
+ FNDA:162,(anonymous_5)
7099
7106
  DA:5,24
7100
7107
  DA:9,24
7101
7108
  DA:10,24
7102
7109
  DA:11,24
7103
- DA:14,7
7104
- DA:17,24
7105
- DA:19,2338
7106
- DA:22,162
7107
- DA:23,1
7108
- DA:26,161
7109
- DA:27,1
7110
- DA:32,160
7111
- DA:34,160
7112
- DA:36,160
7113
- DA:37,160
7114
- DA:38,160
7115
- DA:39,125
7116
- DA:40,35
7117
- DA:41,28
7118
- DA:45,7
7119
- DA:46,7
7120
- DA:49,7
7121
- DA:50,7
7122
- DA:51,7
7123
- DA:52,3
7124
- DA:55,7
7125
- DA:56,1
7126
- DA:57,1
7127
- DA:59,1
7128
- DA:60,6
7129
- DA:61,6
7130
- DA:65,4
7131
- DA:66,4
7132
- DA:69,4
7133
- LF:34
7134
- LH:34
7135
- BRDA:18,0,0,1671
7136
- BRDA:22,1,0,1
7137
- BRDA:22,1,1,161
7138
- BRDA:22,2,0,162
7139
- BRDA:22,2,1,161
7140
- BRDA:26,3,0,1
7141
- BRDA:26,3,1,160
7142
- BRDA:36,4,0,160
7143
- BRDA:36,4,1,160
7144
- BRDA:36,4,2,125
7145
- BRDA:38,5,0,125
7146
- BRDA:38,5,1,35
7147
- BRDA:40,6,0,28
7148
- BRDA:40,6,1,7
7149
- BRDA:40,7,0,35
7150
- BRDA:40,7,1,28
7151
- BRDA:45,8,0,7
7152
- BRDA:45,8,1,4
7153
- BRDA:51,9,0,3
7154
- BRDA:51,9,1,4
7155
- BRDA:55,10,0,1
7156
- BRDA:55,10,1,6
7157
- BRDA:59,11,0,1
7158
- BRDA:59,11,1,0
7159
- BRDA:60,12,0,6
7160
- BRDA:60,12,1,0
7161
- BRDA:65,13,0,4
7162
- BRDA:65,13,1,0
7163
- BRF:28
7164
- BRH:25
7110
+ DA:12,24
7111
+ DA:15,155
7112
+ DA:18,24
7113
+ DA:26,24
7114
+ DA:28,129
7115
+ DA:29,129
7116
+ DA:30,129
7117
+ DA:31,1
7118
+ DA:35,128
7119
+ DA:36,3
7120
+ DA:40,24
7121
+ DA:47,3
7122
+ DA:48,3
7123
+ DA:51,3
7124
+ DA:53,3
7125
+ DA:55,0
7126
+ DA:56,0
7127
+ DA:57,0
7128
+ DA:60,3
7129
+ DA:61,3
7130
+ DA:65,24
7131
+ DA:67,2338
7132
+ DA:70,162
7133
+ DA:71,1
7134
+ DA:74,161
7135
+ DA:75,1
7136
+ DA:80,160
7137
+ DA:83,160
7138
+ DA:84,160
7139
+ DA:85,55
7140
+ DA:89,160
7141
+ DA:90,160
7142
+ DA:91,1
7143
+ DA:95,159
7144
+ DA:96,30
7145
+ DA:100,129
7146
+ DA:103,129
7147
+ LF:41
7148
+ LH:38
7149
+ BRDA:28,0,0,129
7150
+ BRDA:28,0,1,129
7151
+ BRDA:28,0,2,125
7152
+ BRDA:30,1,0,1
7153
+ BRDA:30,1,1,128
7154
+ BRDA:30,2,0,129
7155
+ BRDA:30,2,1,83
7156
+ BRDA:35,3,0,3
7157
+ BRDA:35,3,1,125
7158
+ BRDA:47,4,0,3
7159
+ BRDA:47,4,1,3
7160
+ BRDA:53,5,0,0
7161
+ BRDA:53,5,1,3
7162
+ BRDA:56,6,0,0
7163
+ BRDA:56,6,1,0
7164
+ BRDA:60,7,0,3
7165
+ BRDA:60,7,1,0
7166
+ BRDA:66,8,0,1671
7167
+ BRDA:70,9,0,1
7168
+ BRDA:70,9,1,161
7169
+ BRDA:70,10,0,162
7170
+ BRDA:70,10,1,161
7171
+ BRDA:74,11,0,1
7172
+ BRDA:74,11,1,160
7173
+ BRDA:84,12,0,55
7174
+ BRDA:84,12,1,105
7175
+ BRDA:84,13,0,160
7176
+ BRDA:84,13,1,155
7177
+ BRDA:90,14,0,1
7178
+ BRDA:90,14,1,159
7179
+ BRDA:95,15,0,30
7180
+ BRDA:95,15,1,129
7181
+ BRF:32
7182
+ BRH:28
7165
7183
  end_of_record
7166
7184
  TN:
7167
7185
  SF:src/middleware/builder.js
@@ -24,6 +24,8 @@ exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  const user = yield getFullUser(ctx, userId);
25
25
  // this shouldn't be returned by the app self
26
26
  delete user.roles;
27
+ // forward the csrf token from the session
28
+ user.csrfToken = ctx.user.csrfToken;
27
29
  if (appId) {
28
30
  const db = new CouchDB(appId);
29
31
  // remove the full roles structure
@@ -31,6 +33,8 @@ exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
31
33
  try {
32
34
  const userTable = yield db.get(InternalTables.USER_METADATA);
33
35
  const metadata = yield db.get(userId);
36
+ // make sure there is never a stale csrf token
37
+ delete metadata.csrfToken;
34
38
  // specifically needs to make sure is enriched
35
39
  ctx.body = yield outputProcessing(ctx, userTable, Object.assign(Object.assign({}, user), metadata));
36
40
  }
@@ -155,6 +155,8 @@ exports.updateSelfMetadata = function (ctx) {
155
155
  ctx.request.body._id = ctx.user._id;
156
156
  // make sure no stale rev
157
157
  delete ctx.request.body._rev;
158
+ // make sure no csrf token
159
+ delete ctx.request.body.csrfToken;
158
160
  yield exports.updateMetadata(ctx);
159
161
  });
160
162
  };
@@ -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
- const isAuthed = ctx.isAuthenticated;
32
- // builders for now have permission to do anything
33
- let isBuilder = ctx.user && ctx.user.builder && ctx.user.builder.global;
34
- const isBuilderApi = permType === PermissionTypes.BUILDER;
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
- // need to check this first, in-case public access, don't check authed until last
42
- const roleId = ctx.roleId || BUILTIN_ROLE_IDS.PUBLIC;
43
- const hierarchy = yield getUserRoleHierarchy(ctx.appId, roleId, {
44
- idOnly: false,
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
- // if they are not authed, then anything using the authorized middleware will fail
60
- if (!isAuthed) {
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
- return next();
85
+ // check authorized
86
+ yield checkAuthorized(ctx, resourceRoles, permType, permLevel);
87
+ // csrf protection
88
+ return csrf(ctx, next);
64
89
  });