@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
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.46-alpha.7",
4
+ "version": "1.0.46-alpha.8",
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.7",
74
- "@budibase/client": "^1.0.46-alpha.7",
75
- "@budibase/string-templates": "^1.0.46-alpha.7",
73
+ "@budibase/backend-core": "^1.0.46-alpha.8",
74
+ "@budibase/client": "^1.0.46-alpha.8",
75
+ "@budibase/string-templates": "^1.0.46-alpha.8",
76
76
  "@bull-board/api": "^3.7.0",
77
77
  "@bull-board/koa": "^3.7.0",
78
78
  "@elastic/elasticsearch": "7.10.0",
@@ -168,5 +168,5 @@
168
168
  "optionalDependencies": {
169
169
  "oracledb": "^5.3.0"
170
170
  },
171
- "gitHead": "5718d4925a31131daadf694e7f0ba837084a61f2"
171
+ "gitHead": "d69c417cf4407896917419c6f2dbb3de4ea340d2"
172
172
  }
@@ -16,6 +16,8 @@ exports.fetchSelf = async ctx => {
16
16
  const user = await getFullUser(ctx, userId)
17
17
  // this shouldn't be returned by the app self
18
18
  delete user.roles
19
+ // forward the csrf token from the session
20
+ user.csrfToken = ctx.user.csrfToken
19
21
 
20
22
  if (appId) {
21
23
  const db = new CouchDB(appId)
@@ -24,6 +26,8 @@ exports.fetchSelf = async ctx => {
24
26
  try {
25
27
  const userTable = await db.get(InternalTables.USER_METADATA)
26
28
  const metadata = await db.get(userId)
29
+ // make sure there is never a stale csrf token
30
+ delete metadata.csrfToken
27
31
  // specifically needs to make sure is enriched
28
32
  ctx.body = await outputProcessing(ctx, userTable, {
29
33
  ...user,
@@ -167,6 +167,8 @@ exports.updateSelfMetadata = async function (ctx) {
167
167
  ctx.request.body._id = ctx.user._id
168
168
  // make sure no stale rev
169
169
  delete ctx.request.body._rev
170
+ // make sure no csrf token
171
+ delete ctx.request.body.csrfToken
170
172
  await exports.updateMetadata(ctx)
171
173
  }
172
174
 
@@ -13,10 +13,9 @@ describe("/authenticate", () => {
13
13
 
14
14
  describe("fetch self", () => {
15
15
  it("should be able to fetch self", async () => {
16
- const headers = await config.login()
17
16
  const res = await request
18
17
  .get(`/api/self`)
19
- .set(headers)
18
+ .set(config.defaultHeaders())
20
19
  .expect("Content-Type", /json/)
21
20
  .expect(200)
22
21
  expect(res.body._id).toEqual(generateUserMetadataID("us_uuid1"))
@@ -9,11 +9,59 @@ const {
9
9
  } = require("@budibase/backend-core/permissions")
10
10
  const builderMiddleware = require("./builder")
11
11
  const { isWebhookEndpoint } = require("./utils")
12
+ const { buildCsrfMiddleware } = require("@budibase/backend-core/auth")
12
13
 
13
14
  function hasResource(ctx) {
14
15
  return ctx.resourceId != null
15
16
  }
16
17
 
18
+ const csrf = buildCsrfMiddleware()
19
+
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 = async (ctx, resourceRoles, permType, permLevel) => {
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
+
34
+ // check for resource authorization
35
+ if (!isBuilder) {
36
+ await checkAuthorizedResource(ctx, resourceRoles, permType, permLevel)
37
+ }
38
+ }
39
+
40
+ const checkAuthorizedResource = async (
41
+ ctx,
42
+ resourceRoles,
43
+ permType,
44
+ permLevel
45
+ ) => {
46
+ // get the user's roles
47
+ const roleId = ctx.roleId || BUILTIN_ROLE_IDS.PUBLIC
48
+ const userRoles = await getUserRoleHierarchy(ctx.appId, roleId, {
49
+ idOnly: false,
50
+ })
51
+ const permError = "User does not have permission"
52
+ // check if the user has the required role
53
+ if (resourceRoles.length > 0) {
54
+ // deny access if the user doesn't have the required resource role
55
+ const found = userRoles.find(role => resourceRoles.indexOf(role._id) !== -1)
56
+ if (!found) {
57
+ ctx.throw(403, permError)
58
+ }
59
+ // fallback to the base permissions when no resource roles are found
60
+ } else if (!doesHaveBasePermission(permType, permLevel, userRoles)) {
61
+ ctx.throw(403, permError)
62
+ }
63
+ }
64
+
17
65
  module.exports =
18
66
  (permType, permLevel = null) =>
19
67
  async (ctx, next) => {
@@ -31,40 +79,26 @@ module.exports =
31
79
  // to find API endpoints which are builder focused
32
80
  await builderMiddleware(ctx, permType)
33
81
 
34
- const isAuthed = ctx.isAuthenticated
35
- // builders for now have permission to do anything
36
- let isBuilder = ctx.user && ctx.user.builder && ctx.user.builder.global
37
- const isBuilderApi = permType === PermissionTypes.BUILDER
38
- if (isBuilder) {
39
- return next()
40
- } else if (isBuilderApi && !isBuilder) {
41
- return ctx.throw(403, "Not Authorized")
82
+ // get the resource roles
83
+ let resourceRoles = []
84
+ if (ctx.appId && hasResource(ctx)) {
85
+ resourceRoles = await getRequiredResourceRole(ctx.appId, permLevel, ctx)
42
86
  }
43
87
 
44
- // need to check this first, in-case public access, don't check authed until last
45
- const roleId = ctx.roleId || BUILTIN_ROLE_IDS.PUBLIC
46
- const hierarchy = await getUserRoleHierarchy(ctx.appId, roleId, {
47
- idOnly: false,
48
- })
49
- const permError = "User does not have permission"
50
- let possibleRoleIds = []
51
- if (hasResource(ctx)) {
52
- possibleRoleIds = await getRequiredResourceRole(ctx.appId, permLevel, ctx)
53
- }
54
- // check if we found a role, if not fallback to base permissions
55
- if (possibleRoleIds.length > 0) {
56
- const found = hierarchy.find(
57
- role => possibleRoleIds.indexOf(role._id) !== -1
58
- )
59
- return found ? next() : ctx.throw(403, permError)
60
- } else if (!doesHaveBasePermission(permType, permLevel, hierarchy)) {
61
- ctx.throw(403, permError)
88
+ // if the resource is public, proceed
89
+ const isPublicResource = resourceRoles.includes(BUILTIN_ROLE_IDS.PUBLIC)
90
+ if (isPublicResource) {
91
+ return next()
62
92
  }
63
93
 
64
- // if they are not authed, then anything using the authorized middleware will fail
65
- if (!isAuthed) {
66
- ctx.throw(403, "Session not authenticated")
94
+ // check authenticated
95
+ if (!ctx.isAuthenticated) {
96
+ return ctx.throw(403, "Session not authenticated")
67
97
  }
68
98
 
69
- return next()
99
+ // check authorized
100
+ await checkAuthorized(ctx, resourceRoles, permType, permLevel)
101
+
102
+ // csrf protection
103
+ return csrf(ctx, next)
70
104
  }
@@ -17,6 +17,7 @@ class TestConfiguration {
17
17
  this.middleware = authorizedMiddleware(role)
18
18
  this.next = jest.fn()
19
19
  this.throw = jest.fn()
20
+ this.headers = {}
20
21
  this.ctx = {
21
22
  headers: {},
22
23
  request: {
@@ -25,7 +26,8 @@ class TestConfiguration {
25
26
  appId: "",
26
27
  auth: {},
27
28
  next: this.next,
28
- throw: this.throw
29
+ throw: this.throw,
30
+ get: (name) => this.headers[name],
29
31
  }
30
32
  }
31
33
 
@@ -46,7 +48,7 @@ class TestConfiguration {
46
48
  }
47
49
 
48
50
  setAuthenticated(isAuthed) {
49
- this.ctx.auth = { authenticated: isAuthed }
51
+ this.ctx.isAuthenticated = isAuthed
50
52
  }
51
53
 
52
54
  setRequestUrl(url) {
@@ -107,7 +109,7 @@ describe("Authorization middleware", () => {
107
109
  expect(config.next).toHaveBeenCalled()
108
110
  })
109
111
 
110
- it("throws if the user has only builder permissions", async () => {
112
+ it("throws if the user does not have builder permissions", async () => {
111
113
  config.setEnvironment(false)
112
114
  config.setMiddlewareRequiredPermission(PermissionTypes.BUILDER)
113
115
  config.setUser({
@@ -133,7 +135,7 @@ describe("Authorization middleware", () => {
133
135
  expect(config.next).toHaveBeenCalled()
134
136
  })
135
137
 
136
- it("throws if the user session is not authenticated after permission checks", async () => {
138
+ it("throws if the user session is not authenticated", async () => {
137
139
  config.setUser({
138
140
  role: {
139
141
  _id: ""
@@ -27,6 +27,7 @@ core.init(CouchDB)
27
27
 
28
28
  const GLOBAL_USER_ID = "us_uuid1"
29
29
  const EMAIL = "babs@babs.com"
30
+ const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
30
31
 
31
32
  class TestConfiguration {
32
33
  constructor(openServer = true) {
@@ -86,7 +87,11 @@ class TestConfiguration {
86
87
  roles: roles || {},
87
88
  tenantId: TENANT_ID,
88
89
  }
89
- await createASession(id, { sessionId: "sessionid", tenantId: TENANT_ID })
90
+ await createASession(id, {
91
+ sessionId: "sessionid",
92
+ tenantId: TENANT_ID,
93
+ csrfToken: CSRF_TOKEN,
94
+ })
90
95
  if (builder) {
91
96
  user.builder = { global: true }
92
97
  } else {
@@ -133,6 +138,7 @@ class TestConfiguration {
133
138
  `${Cookies.Auth}=${authToken}`,
134
139
  `${Cookies.CurrentApp}=${appToken}`,
135
140
  ],
141
+ [Headers.CSRF_TOKEN]: CSRF_TOKEN,
136
142
  }
137
143
  if (this.appId) {
138
144
  headers[Headers.APP_ID] = this.appId
@@ -426,10 +432,6 @@ class TestConfiguration {
426
432
  roles: { [this.prodAppId]: roleId },
427
433
  })
428
434
  }
429
- await createASession(userId, {
430
- sessionId: "sessionid",
431
- tenantId: TENANT_ID,
432
- })
433
435
  // have to fake this
434
436
  const auth = {
435
437
  userId,