@budibase/worker 2.1.22-alpha.5 → 2.1.22-alpha.7
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/__mocks__/oauth.ts +57 -0
- package/coverage/clover.xml +1255 -1174
- package/coverage/coverage-final.json +77 -72
- package/coverage/lcov-report/index.html +96 -96
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +110 -98
- package/coverage/lcov-report/src/api/controllers/global/configs.js.html +52 -52
- package/coverage/lcov-report/src/api/controllers/global/email.js.html +4 -4
- package/coverage/lcov-report/src/api/controllers/global/index.html +38 -38
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/global/roles.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +59 -59
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +11 -11
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +75 -69
- package/coverage/lcov-report/src/api/controllers/global/workspaces.js.html +7 -7
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/system/{environment.js.html → environment.ts.html} +21 -18
- package/coverage/lcov-report/src/api/controllers/system/index.html +63 -63
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +23 -23
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +22 -22
- package/coverage/lcov-report/src/api/controllers/system/{status.js.html → status.ts.html} +29 -26
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +34 -163
- package/coverage/lcov-report/src/api/index.html +11 -11
- package/coverage/lcov-report/src/api/index.ts.html +113 -44
- package/coverage/lcov-report/src/api/routes/global/auth.js.html +38 -89
- package/coverage/lcov-report/src/api/routes/global/configs.js.html +26 -26
- package/coverage/lcov-report/src/api/routes/global/email.js.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/index.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/global/roles.js.html +7 -7
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/global/users.js.html +17 -17
- package/coverage/lcov-report/src/api/routes/global/workspaces.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.ts.html +19 -19
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/system/{environment.js.html → environment.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/system/index.html +4 -4
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/system/{status.js.html → status.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/system/{tenants.js.html → tenants.ts.html} +20 -17
- package/coverage/lcov-report/src/api/routes/validation/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +2 -2
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +13 -13
- package/coverage/lcov-report/src/constants/index.html +10 -10
- package/coverage/lcov-report/src/constants/{index.js.html → index.ts.html} +103 -124
- package/coverage/lcov-report/src/constants/templates/index.html +1 -1
- package/coverage/lcov-report/src/constants/templates/index.js.html +12 -12
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.ts.html +8 -8
- package/coverage/lcov-report/src/environment.ts.html +15 -15
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +40 -40
- package/coverage/lcov-report/src/middleware/cloudRestricted.js.html +23 -23
- package/coverage/lcov-report/src/middleware/index.html +21 -21
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +17 -17
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/accounts/index.html +1 -1
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/index.html +1 -1
- package/coverage/lcov-report/src/sdk/index.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/users/events.ts.html +43 -43
- package/coverage/lcov-report/src/sdk/users/index.html +19 -19
- package/coverage/lcov-report/src/sdk/users/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/users/users.ts.html +99 -99
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +275 -128
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +12 -21
- package/coverage/lcov-report/src/tests/api/auth.ts.html +11 -20
- package/coverage/lcov-report/src/tests/api/base.ts.html +133 -0
- package/coverage/lcov-report/src/tests/api/configs.ts.html +44 -23
- package/coverage/lcov-report/src/tests/api/email.ts.html +9 -18
- package/coverage/lcov-report/src/tests/api/environment.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/index.html +106 -16
- package/coverage/lcov-report/src/tests/api/index.ts.html +62 -17
- package/coverage/lcov-report/src/tests/{structures/accounts.ts.html → api/migrations.ts.html} +31 -37
- package/coverage/lcov-report/src/tests/api/restore.ts.html +127 -0
- package/coverage/lcov-report/src/tests/api/self.ts.html +31 -16
- package/coverage/lcov-report/src/tests/api/status.ts.html +121 -0
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/users.ts.html +121 -25
- package/coverage/lcov-report/src/tests/controllers.js.html +2 -2
- package/coverage/lcov-report/src/tests/index.html +21 -21
- package/coverage/lcov-report/src/tests/index.ts.html +21 -9
- package/coverage/lcov-report/src/tests/mocks/email.js.html +2 -2
- package/coverage/lcov-report/src/tests/mocks/index.html +1 -1
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +4 -4
- package/coverage/lcov-report/src/tests/structures/configs.js.html +14 -14
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +2 -2
- package/coverage/lcov-report/src/tests/structures/index.html +9 -24
- package/coverage/lcov-report/src/tests/structures/index.ts.html +21 -15
- package/coverage/lcov-report/src/tests/structures/users.ts.html +13 -10
- package/coverage/lcov-report/src/utilities/appService.js.html +14 -14
- package/coverage/lcov-report/src/utilities/{email.js.html → email.ts.html} +172 -73
- package/coverage/lcov-report/src/utilities/fileSystem.js.html +4 -4
- package/coverage/lcov-report/src/utilities/index.html +23 -23
- package/coverage/lcov-report/src/utilities/index.js.html +2 -2
- package/coverage/lcov-report/src/utilities/{redis.js.html → redis.ts.html} +63 -48
- package/coverage/lcov-report/src/utilities/{templates.js.html → templates.ts.html} +41 -41
- package/coverage/lcov-report/src/utilities/users.js.html +8 -8
- package/coverage/lcov.info +2058 -1820
- package/jest.config.ts +1 -0
- package/package.json +8 -6
- package/scripts/localdomain.js +33 -7
- package/src/api/controllers/global/auth.ts +35 -31
- package/src/api/controllers/global/configs.js +17 -17
- package/src/api/controllers/global/self.ts +2 -2
- package/src/api/controllers/global/users.ts +3 -1
- package/src/api/controllers/system/{environment.js → environment.ts} +3 -2
- package/src/api/controllers/system/{status.js → status.ts} +4 -3
- package/src/api/controllers/system/tenants.ts +8 -51
- package/src/api/index.ts +29 -6
- package/src/api/routes/global/auth.js +22 -39
- package/src/api/routes/global/configs.js +9 -9
- package/src/api/routes/global/templates.ts +2 -2
- package/src/api/routes/global/tests/auth.spec.ts +134 -64
- package/src/api/routes/global/tests/configs.spec.ts +34 -35
- package/src/api/routes/global/tests/email.spec.ts +4 -3
- package/src/api/routes/global/tests/license.spec.ts +31 -0
- package/src/api/routes/global/tests/realEmail.spec.ts +2 -3
- package/src/api/routes/global/tests/roles.spec.ts +27 -0
- package/src/api/routes/global/tests/self.spec.ts +3 -4
- package/src/api/routes/global/tests/templates.spec.ts +35 -0
- package/src/api/routes/global/tests/users.spec.ts +51 -43
- package/src/api/routes/global/tests/workspaces.spec.ts +29 -0
- package/src/api/routes/system/environment.ts +8 -0
- package/src/api/routes/system/status.ts +8 -0
- package/src/api/routes/system/tenants.ts +13 -0
- package/src/api/routes/system/tests/accounts.spec.ts +5 -6
- package/src/api/routes/system/tests/environment.spec.ts +29 -0
- package/src/api/routes/system/tests/migrations.spec.ts +63 -0
- package/src/api/routes/system/tests/restore.spec.ts +36 -0
- package/src/api/routes/system/tests/status.spec.ts +48 -0
- package/src/api/routes/system/tests/tenants.spec.ts +61 -0
- package/src/constants/{index.js → index.ts} +57 -64
- package/src/constants/templates/index.js +2 -2
- package/src/middleware/cloudRestricted.js +2 -2
- package/src/middleware/tests/tenancy.spec.ts +73 -0
- package/src/tests/TestConfiguration.ts +97 -48
- package/src/tests/api/accounts.ts +5 -8
- package/src/tests/api/auth.ts +3 -6
- package/src/tests/api/base.ts +16 -0
- package/src/tests/api/configs.ts +15 -8
- package/src/tests/api/email.ts +3 -6
- package/src/tests/api/environment.ts +15 -0
- package/src/tests/api/index.ts +15 -0
- package/src/tests/api/migrations.ts +22 -0
- package/src/tests/api/restore.ts +14 -0
- package/src/tests/api/self.ts +11 -6
- package/src/tests/api/status.ts +12 -0
- package/src/tests/api/tenants.ts +15 -0
- package/src/tests/api/users.ts +38 -6
- package/src/tests/index.ts +4 -0
- package/src/tests/jestSetup.ts +7 -1
- package/src/tests/structures/configs.js +6 -6
- package/src/tests/structures/index.ts +4 -2
- package/src/tests/structures/users.ts +1 -0
- package/src/utilities/appService.js +3 -3
- package/src/utilities/{email.js → email.ts} +78 -45
- package/src/utilities/{redis.js → redis.ts} +29 -24
- package/src/utilities/templates.ts +49 -0
- package/tsconfig.build.json +3 -3
- package/__mocks__/node-fetch.ts +0 -1
- package/src/api/routes/system/environment.js +0 -8
- package/src/api/routes/system/status.js +0 -8
- package/src/api/routes/system/tenants.js +0 -12
- package/src/tests/structures/accounts.ts +0 -24
- package/src/utilities/templates.js +0 -49
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">64.51% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>100/155</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">48.83% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>21/43</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">61.47% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>75/122</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -335,49 +335,57 @@
|
|
|
335
335
|
<a name='L270'></a><a href='#L270'>270</a>
|
|
336
336
|
<a name='L271'></a><a href='#L271'>271</a>
|
|
337
337
|
<a name='L272'></a><a href='#L272'>272</a>
|
|
338
|
-
<a name='L273'></a><a href='#L273'>273</a
|
|
339
|
-
<
|
|
340
|
-
<
|
|
341
|
-
<
|
|
342
|
-
<span class="cline-any cline-yes">
|
|
343
|
-
<span class="cline-any cline-yes">
|
|
344
|
-
<span class="cline-any cline-yes">7x</span>
|
|
345
|
-
<span class="cline-any cline-yes">7x</span>
|
|
346
|
-
<span class="cline-any cline-yes">7x</span>
|
|
347
|
-
<span class="cline-any cline-yes">7x</span>
|
|
348
|
-
<span class="cline-any cline-yes">7x</span>
|
|
338
|
+
<a name='L273'></a><a href='#L273'>273</a>
|
|
339
|
+
<a name='L274'></a><a href='#L274'>274</a>
|
|
340
|
+
<a name='L275'></a><a href='#L275'>275</a>
|
|
341
|
+
<a name='L276'></a><a href='#L276'>276</a>
|
|
342
|
+
<a name='L277'></a><a href='#L277'>277</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">17x</span>
|
|
343
|
+
<span class="cline-any cline-yes">17x</span>
|
|
349
344
|
<span class="cline-any cline-neutral"> </span>
|
|
350
345
|
<span class="cline-any cline-neutral"> </span>
|
|
351
|
-
<span class="cline-any cline-yes">7x</span>
|
|
352
|
-
<span class="cline-any cline-no"> </span>
|
|
353
346
|
<span class="cline-any cline-neutral"> </span>
|
|
354
347
|
<span class="cline-any cline-neutral"> </span>
|
|
355
|
-
<span class="cline-any cline-yes">7x</span>
|
|
356
|
-
<span class="cline-any cline-yes">2x</span>
|
|
357
348
|
<span class="cline-any cline-neutral"> </span>
|
|
349
|
+
<span class="cline-any cline-yes">17x</span>
|
|
350
|
+
<span class="cline-any cline-yes">17x</span>
|
|
351
|
+
<span class="cline-any cline-yes">17x</span>
|
|
352
|
+
<span class="cline-any cline-yes">17x</span>
|
|
353
|
+
<span class="cline-any cline-yes">17x</span>
|
|
358
354
|
<span class="cline-any cline-neutral"> </span>
|
|
355
|
+
<span class="cline-any cline-yes">17x</span>
|
|
356
|
+
<span class="cline-any cline-yes">17x</span>
|
|
357
|
+
<span class="cline-any cline-yes">17x</span>
|
|
359
358
|
<span class="cline-any cline-neutral"> </span>
|
|
359
|
+
<span class="cline-any cline-yes">17x</span>
|
|
360
360
|
<span class="cline-any cline-no"> </span>
|
|
361
|
+
<span class="cline-any cline-neutral"> </span>
|
|
362
|
+
<span class="cline-any cline-neutral"> </span>
|
|
363
|
+
<span class="cline-any cline-yes">17x</span>
|
|
364
|
+
<span class="cline-any cline-yes">3x</span>
|
|
365
|
+
<span class="cline-any cline-neutral"> </span>
|
|
366
|
+
<span class="cline-any cline-neutral"> </span>
|
|
367
|
+
<span class="cline-any cline-neutral"> </span>
|
|
368
|
+
<span class="cline-any cline-yes">1x</span>
|
|
361
369
|
<span class="cline-any cline-no"> </span>
|
|
362
370
|
<span class="cline-any cline-no"> </span>
|
|
363
371
|
<span class="cline-any cline-neutral"> </span>
|
|
364
372
|
<span class="cline-any cline-neutral"> </span>
|
|
365
|
-
<span class="cline-any cline-
|
|
373
|
+
<span class="cline-any cline-yes">1x</span>
|
|
366
374
|
<span class="cline-any cline-no"> </span>
|
|
367
375
|
<span class="cline-any cline-neutral"> </span>
|
|
368
376
|
<span class="cline-any cline-neutral"> </span>
|
|
369
377
|
<span class="cline-any cline-neutral"> </span>
|
|
370
|
-
<span class="cline-any cline-
|
|
378
|
+
<span class="cline-any cline-yes">1x</span>
|
|
371
379
|
<span class="cline-any cline-neutral"> </span>
|
|
372
|
-
<span class="cline-any cline-
|
|
380
|
+
<span class="cline-any cline-yes">1x</span>
|
|
373
381
|
<span class="cline-any cline-neutral"> </span>
|
|
374
382
|
<span class="cline-any cline-neutral"> </span>
|
|
375
|
-
<span class="cline-any cline-
|
|
383
|
+
<span class="cline-any cline-yes">1x</span>
|
|
376
384
|
<span class="cline-any cline-no"> </span>
|
|
377
385
|
<span class="cline-any cline-neutral"> </span>
|
|
378
386
|
<span class="cline-any cline-neutral"> </span>
|
|
379
387
|
<span class="cline-any cline-neutral"> </span>
|
|
380
|
-
<span class="cline-any cline-yes">
|
|
388
|
+
<span class="cline-any cline-yes">17x</span>
|
|
381
389
|
<span class="cline-any cline-no"> </span>
|
|
382
390
|
<span class="cline-any cline-neutral"> </span>
|
|
383
391
|
<span class="cline-any cline-no"> </span>
|
|
@@ -390,13 +398,13 @@
|
|
|
390
398
|
<span class="cline-any cline-neutral"> </span>
|
|
391
399
|
<span class="cline-any cline-neutral"> </span>
|
|
392
400
|
<span class="cline-any cline-neutral"> </span>
|
|
393
|
-
<span class="cline-any cline-yes">
|
|
401
|
+
<span class="cline-any cline-yes">17x</span>
|
|
394
402
|
<span class="cline-any cline-no"> </span>
|
|
395
403
|
<span class="cline-any cline-no"> </span>
|
|
396
404
|
<span class="cline-any cline-no"> </span>
|
|
397
405
|
<span class="cline-any cline-neutral"> </span>
|
|
398
406
|
<span class="cline-any cline-neutral"> </span>
|
|
399
|
-
<span class="cline-any cline-yes">
|
|
407
|
+
<span class="cline-any cline-yes">17x</span>
|
|
400
408
|
<span class="cline-any cline-no"> </span>
|
|
401
409
|
<span class="cline-any cline-no"> </span>
|
|
402
410
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -408,7 +416,7 @@
|
|
|
408
416
|
<span class="cline-any cline-neutral"> </span>
|
|
409
417
|
<span class="cline-any cline-neutral"> </span>
|
|
410
418
|
<span class="cline-any cline-neutral"> </span>
|
|
411
|
-
<span class="cline-any cline-yes">
|
|
419
|
+
<span class="cline-any cline-yes">17x</span>
|
|
412
420
|
<span class="cline-any cline-yes">2x</span>
|
|
413
421
|
<span class="cline-any cline-yes">2x</span>
|
|
414
422
|
<span class="cline-any cline-yes">2x</span>
|
|
@@ -439,7 +447,7 @@
|
|
|
439
447
|
<span class="cline-any cline-neutral"> </span>
|
|
440
448
|
<span class="cline-any cline-neutral"> </span>
|
|
441
449
|
<span class="cline-any cline-neutral"> </span>
|
|
442
|
-
<span class="cline-any cline-yes">
|
|
450
|
+
<span class="cline-any cline-yes">17x</span>
|
|
443
451
|
<span class="cline-any cline-yes">1x</span>
|
|
444
452
|
<span class="cline-any cline-yes">1x</span>
|
|
445
453
|
<span class="cline-any cline-yes">1x</span>
|
|
@@ -459,14 +467,14 @@
|
|
|
459
467
|
<span class="cline-any cline-neutral"> </span>
|
|
460
468
|
<span class="cline-any cline-neutral"> </span>
|
|
461
469
|
<span class="cline-any cline-neutral"> </span>
|
|
462
|
-
<span class="cline-any cline-yes">
|
|
470
|
+
<span class="cline-any cline-yes">17x</span>
|
|
463
471
|
<span class="cline-any cline-yes">1x</span>
|
|
464
472
|
<span class="cline-any cline-yes">1x</span>
|
|
465
473
|
<span class="cline-any cline-neutral"> </span>
|
|
466
474
|
<span class="cline-any cline-yes">1x</span>
|
|
467
475
|
<span class="cline-any cline-neutral"> </span>
|
|
468
476
|
<span class="cline-any cline-neutral"> </span>
|
|
469
|
-
<span class="cline-any cline-yes">
|
|
477
|
+
<span class="cline-any cline-yes">17x</span>
|
|
470
478
|
<span class="cline-any cline-no"> </span>
|
|
471
479
|
<span class="cline-any cline-no"> </span>
|
|
472
480
|
<span class="cline-any cline-no"> </span>
|
|
@@ -484,7 +492,7 @@
|
|
|
484
492
|
<span class="cline-any cline-no"> </span>
|
|
485
493
|
<span class="cline-any cline-neutral"> </span>
|
|
486
494
|
<span class="cline-any cline-neutral"> </span>
|
|
487
|
-
<span class="cline-any cline-yes">
|
|
495
|
+
<span class="cline-any cline-yes">17x</span>
|
|
488
496
|
<span class="cline-any cline-no"> </span>
|
|
489
497
|
<span class="cline-any cline-no"> </span>
|
|
490
498
|
<span class="cline-any cline-no"> </span>
|
|
@@ -496,7 +504,7 @@
|
|
|
496
504
|
<span class="cline-any cline-neutral"> </span>
|
|
497
505
|
<span class="cline-any cline-neutral"> </span>
|
|
498
506
|
<span class="cline-any cline-neutral"> </span>
|
|
499
|
-
<span class="cline-any cline-yes">
|
|
507
|
+
<span class="cline-any cline-yes">17x</span>
|
|
500
508
|
<span class="cline-any cline-no"> </span>
|
|
501
509
|
<span class="cline-any cline-neutral"> </span>
|
|
502
510
|
<span class="cline-any cline-no"> </span>
|
|
@@ -517,7 +525,7 @@
|
|
|
517
525
|
<span class="cline-any cline-neutral"> </span>
|
|
518
526
|
<span class="cline-any cline-neutral"> </span>
|
|
519
527
|
<span class="cline-any cline-neutral"> </span>
|
|
520
|
-
<span class="cline-any cline-yes">
|
|
528
|
+
<span class="cline-any cline-yes">17x</span>
|
|
521
529
|
<span class="cline-any cline-no"> </span>
|
|
522
530
|
<span class="cline-any cline-neutral"> </span>
|
|
523
531
|
<span class="cline-any cline-no"> </span>
|
|
@@ -544,108 +552,112 @@
|
|
|
544
552
|
<span class="cline-any cline-neutral"> </span>
|
|
545
553
|
<span class="cline-any cline-neutral"> </span>
|
|
546
554
|
<span class="cline-any cline-neutral"> </span>
|
|
547
|
-
<span class="cline-any cline-yes">
|
|
548
|
-
<span class="cline-any cline-yes">
|
|
549
|
-
<span class="cline-any cline-yes">
|
|
555
|
+
<span class="cline-any cline-yes">17x</span>
|
|
556
|
+
<span class="cline-any cline-yes">3x</span>
|
|
557
|
+
<span class="cline-any cline-yes">3x</span>
|
|
550
558
|
<span class="cline-any cline-neutral"> </span>
|
|
551
559
|
<span class="cline-any cline-neutral"> </span>
|
|
552
560
|
<span class="cline-any cline-neutral"> </span>
|
|
553
561
|
<span class="cline-any cline-neutral"> </span>
|
|
554
|
-
<span class="cline-any cline-yes">
|
|
555
|
-
<span class="cline-any cline-yes">
|
|
562
|
+
<span class="cline-any cline-yes">3x</span>
|
|
563
|
+
<span class="cline-any cline-yes">3x</span>
|
|
556
564
|
<span class="cline-any cline-neutral"> </span>
|
|
557
565
|
<span class="cline-any cline-neutral"> </span>
|
|
558
|
-
<span class="cline-any cline-yes">
|
|
566
|
+
<span class="cline-any cline-yes">3x</span>
|
|
559
567
|
<span class="cline-any cline-neutral"> </span>
|
|
560
568
|
<span class="cline-any cline-neutral"> </span>
|
|
561
569
|
<span class="cline-any cline-neutral"> </span>
|
|
562
|
-
<span class="cline-any cline-yes">
|
|
570
|
+
<span class="cline-any cline-yes">3x</span>
|
|
563
571
|
<span class="cline-any cline-neutral"> </span>
|
|
564
572
|
<span class="cline-any cline-neutral"> </span>
|
|
565
573
|
<span class="cline-any cline-neutral"> </span>
|
|
566
574
|
<span class="cline-any cline-neutral"> </span>
|
|
567
575
|
<span class="cline-any cline-neutral"> </span>
|
|
568
576
|
<span class="cline-any cline-neutral"> </span>
|
|
569
|
-
<span class="cline-any cline-yes">
|
|
570
|
-
<span class="cline-any cline-yes">
|
|
571
|
-
<span class="cline-any cline-yes">
|
|
577
|
+
<span class="cline-any cline-yes">17x</span>
|
|
578
|
+
<span class="cline-any cline-yes">2x</span>
|
|
579
|
+
<span class="cline-any cline-yes">2x</span>
|
|
572
580
|
<span class="cline-any cline-neutral"> </span>
|
|
573
|
-
<span class="cline-any cline-yes">
|
|
581
|
+
<span class="cline-any cline-yes">2x</span>
|
|
574
582
|
<span class="cline-any cline-neutral"> </span>
|
|
575
|
-
<span class="cline-any cline-yes">
|
|
576
|
-
<span class="cline-any cline-yes">
|
|
583
|
+
<span class="cline-any cline-yes">2x</span>
|
|
584
|
+
<span class="cline-any cline-yes">2x</span>
|
|
577
585
|
<span class="cline-any cline-neutral"> </span>
|
|
578
586
|
<span class="cline-any cline-neutral"> </span>
|
|
579
587
|
<span class="cline-any cline-neutral"> </span>
|
|
580
588
|
<span class="cline-any cline-neutral"> </span>
|
|
581
|
-
<span class="cline-any cline-yes">
|
|
589
|
+
<span class="cline-any cline-yes">2x</span>
|
|
582
590
|
<span class="cline-any cline-neutral"> </span>
|
|
583
591
|
<span class="cline-any cline-neutral"> </span>
|
|
584
|
-
<span class="cline-any cline-yes">
|
|
592
|
+
<span class="cline-any cline-yes">2x</span>
|
|
585
593
|
<span class="cline-any cline-neutral"> </span>
|
|
586
594
|
<span class="cline-any cline-neutral"> </span>
|
|
587
595
|
<span class="cline-any cline-neutral"> </span>
|
|
588
|
-
<span class="cline-any cline-yes">
|
|
596
|
+
<span class="cline-any cline-yes">2x</span>
|
|
589
597
|
<span class="cline-any cline-neutral"> </span>
|
|
590
598
|
<span class="cline-any cline-neutral"> </span>
|
|
591
599
|
<span class="cline-any cline-neutral"> </span>
|
|
592
600
|
<span class="cline-any cline-neutral"> </span>
|
|
593
601
|
<span class="cline-any cline-neutral"> </span>
|
|
594
|
-
<span class="cline-any cline-yes">
|
|
602
|
+
<span class="cline-any cline-yes">17x</span>
|
|
595
603
|
<span class="cline-any cline-yes">1x</span>
|
|
596
604
|
<span class="cline-any cline-yes">1x</span>
|
|
597
605
|
<span class="cline-any cline-neutral"> </span>
|
|
598
606
|
<span class="cline-any cline-yes">1x</span>
|
|
599
607
|
<span class="cline-any cline-neutral"> </span>
|
|
600
608
|
<span class="cline-any cline-neutral"> </span>
|
|
601
|
-
<span class="cline-any cline-
|
|
602
|
-
<span class="cline-any cline-
|
|
603
|
-
<span class="cline-any cline-
|
|
604
|
-
<span class="cline-any cline-
|
|
609
|
+
<span class="cline-any cline-yes">1x</span>
|
|
610
|
+
<span class="cline-any cline-yes">1x</span>
|
|
611
|
+
<span class="cline-any cline-yes">1x</span>
|
|
612
|
+
<span class="cline-any cline-yes">1x</span>
|
|
605
613
|
<span class="cline-any cline-neutral"> </span>
|
|
606
|
-
<span class="cline-any cline-
|
|
614
|
+
<span class="cline-any cline-yes">1x</span>
|
|
607
615
|
<span class="cline-any cline-neutral"> </span>
|
|
608
616
|
<span class="cline-any cline-neutral"> </span>
|
|
609
617
|
<span class="cline-any cline-neutral"> </span>
|
|
610
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
import {
|
|
618
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import core from "@budibase/backend-core"
|
|
619
|
+
import {
|
|
620
|
+
events,
|
|
621
|
+
users as usersCore,
|
|
622
|
+
context,
|
|
623
|
+
tenancy,
|
|
624
|
+
} from "@budibase/backend-core"
|
|
625
|
+
import { Config, EmailTemplatePurpose } from "../../../constants"
|
|
626
|
+
import { sendEmail, isEmailConfigured } from "../../../utilities/email"
|
|
627
|
+
import { checkResetPasswordCode } from "../../../utilities/redis"
|
|
628
|
+
import env from "../../../environment"
|
|
620
629
|
import sdk from "../../../sdk"
|
|
621
630
|
import { User } from "@budibase/types"
|
|
631
|
+
const { setCookie, getCookie, clearCookie, hash, platformLogout } = core.utils
|
|
632
|
+
const { Cookie, Header } = core.constants
|
|
633
|
+
const { passport, ssoCallbackUrl, google, oidc } = core.auth
|
|
622
634
|
|
|
623
635
|
export const googleCallbackUrl = <span class="fstat-no" title="function not covered" >async (c</span>onfig: any) =><span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > {</span></span>
|
|
624
|
-
<span class="cstat-no" title="statement not covered" > return ssoCallbackUrl(getGlobalDB(), config, "google")</span>
|
|
636
|
+
<span class="cstat-no" title="statement not covered" > return ssoCallbackUrl(tenancy.getGlobalDB(), config, "google")</span>
|
|
625
637
|
}
|
|
626
638
|
|
|
627
639
|
export const oidcCallbackUrl = async (config: any) => {
|
|
628
|
-
return ssoCallbackUrl(getGlobalDB(), config, "oidc")
|
|
640
|
+
return ssoCallbackUrl(tenancy.getGlobalDB(), config, "oidc")
|
|
629
641
|
}
|
|
630
642
|
|
|
631
|
-
async function
|
|
632
|
-
|
|
643
|
+
async function authInternal(ctx: any, user: any, err = <span class="branch-0 cbranch-no" title="branch not covered" >null,</span> info = <span class="branch-0 cbranch-no" title="branch not covered" >null)</span> {
|
|
644
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (err) {
|
|
633
645
|
<span class="cstat-no" title="statement not covered" > console.error("Authentication error", err)</span>
|
|
634
646
|
<span class="cstat-no" title="statement not covered" > return ctx.throw(403, info ? info : "Unauthorized")</span>
|
|
635
647
|
}
|
|
636
648
|
|
|
637
|
-
|
|
649
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (!user) {
|
|
638
650
|
<span class="cstat-no" title="statement not covered" > return ctx.throw(403, info ? info : "Unauthorized")</span>
|
|
639
651
|
}
|
|
640
652
|
|
|
641
653
|
// set a cookie for browser access
|
|
642
|
-
|
|
654
|
+
setCookie(ctx, user.token, Cookie.Auth, { sign: false })
|
|
643
655
|
// set the token in a header as well for APIs
|
|
644
|
-
|
|
656
|
+
ctx.set(Header.TOKEN, user.token)
|
|
645
657
|
// get rid of any app cookies on login
|
|
646
658
|
// have to check test because this breaks cypress
|
|
647
|
-
|
|
648
|
-
<span class="cstat-no" title="statement not covered" > clearCookie(ctx,
|
|
659
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (!env.isTest()) {
|
|
660
|
+
<span class="cstat-no" title="statement not covered" > clearCookie(ctx, Cookie.CurrentApp)</span>
|
|
649
661
|
}
|
|
650
662
|
}
|
|
651
663
|
|
|
@@ -664,15 +676,15 @@ export const authenticate = <span class="fstat-no" title="function not covered"
|
|
|
664
676
|
|
|
665
677
|
export const setInitInfo = <span class="fstat-no" title="function not covered" >(c</span>tx: any) => {
|
|
666
678
|
const initInfo = <span class="cstat-no" title="statement not covered" >ctx.request.body</span>
|
|
667
|
-
<span class="cstat-no" title="statement not covered" > setCookie(ctx, initInfo,
|
|
679
|
+
<span class="cstat-no" title="statement not covered" > setCookie(ctx, initInfo, Cookie.Init)</span>
|
|
668
680
|
<span class="cstat-no" title="statement not covered" > ctx.status = 200</span>
|
|
669
681
|
}
|
|
670
682
|
|
|
671
683
|
export const getInitInfo = <span class="fstat-no" title="function not covered" >(c</span>tx: any) => {
|
|
672
684
|
<span class="cstat-no" title="statement not covered" > try {</span>
|
|
673
|
-
<span class="cstat-no" title="statement not covered" > ctx.body = getCookie(ctx,
|
|
685
|
+
<span class="cstat-no" title="statement not covered" > ctx.body = getCookie(ctx, Cookie.Init) || {}</span>
|
|
674
686
|
} catch (err) {
|
|
675
|
-
<span class="cstat-no" title="statement not covered" > clearCookie(ctx,
|
|
687
|
+
<span class="cstat-no" title="statement not covered" > clearCookie(ctx, Cookie.Init)</span>
|
|
676
688
|
<span class="cstat-no" title="statement not covered" > ctx.body = {}</span>
|
|
677
689
|
}
|
|
678
690
|
}
|
|
@@ -715,7 +727,7 @@ export const resetUpdate = async (ctx: any) => {
|
|
|
715
727
|
const { resetCode, password } = ctx.request.body
|
|
716
728
|
try {
|
|
717
729
|
const { userId } = await checkResetPasswordCode(resetCode)
|
|
718
|
-
const db = getGlobalDB()
|
|
730
|
+
const db = tenancy.getGlobalDB()
|
|
719
731
|
const user = await db.get(userId)
|
|
720
732
|
user.password = await hash(password)
|
|
721
733
|
await db.put(user)
|
|
@@ -750,14 +762,14 @@ export const datasourcePreAuth = <span class="fstat-no" title="function not cove
|
|
|
750
762
|
appId: ctx.query.appId,
|
|
751
763
|
datasourceId: ctx.query.datasourceId,
|
|
752
764
|
},
|
|
753
|
-
|
|
765
|
+
Cookie.DatasourceAuth
|
|
754
766
|
)
|
|
755
767
|
|
|
756
768
|
<span class="cstat-no" title="statement not covered" > return handler.preAuth(passport, ctx, next)</span>
|
|
757
769
|
}
|
|
758
770
|
|
|
759
771
|
export const datasourceAuth = <span class="fstat-no" title="function not covered" >async (c</span>tx: any, next: any) =><span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > {</span></span>
|
|
760
|
-
const authStateCookie = <span class="cstat-no" title="statement not covered" >getCookie(ctx,
|
|
772
|
+
const authStateCookie = <span class="cstat-no" title="statement not covered" >getCookie(ctx, Cookie.DatasourceAuth)</span>
|
|
761
773
|
const provider = <span class="cstat-no" title="statement not covered" >authStateCookie.provider</span>
|
|
762
774
|
const middleware = <span class="cstat-no" title="statement not covered" >require(`@budibase/backend-core/middleware`)</span>
|
|
763
775
|
const handler = <span class="cstat-no" title="statement not covered" >middleware.datasource[provider]</span>
|
|
@@ -769,10 +781,10 @@ export const datasourceAuth = <span class="fstat-no" title="function not covered
|
|
|
769
781
|
* On a successful login, you will be redirected to the googleAuth callback route.
|
|
770
782
|
*/
|
|
771
783
|
export const googlePreAuth = <span class="fstat-no" title="function not covered" >async (c</span>tx: any, next: any) =><span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > {</span></span>
|
|
772
|
-
const db = <span class="cstat-no" title="statement not covered" >getGlobalDB()</span>
|
|
784
|
+
const db = <span class="cstat-no" title="statement not covered" >tenancy.getGlobalDB()</span>
|
|
773
785
|
|
|
774
786
|
const config = <span class="cstat-no" title="statement not covered" >await core.db.getScopedConfig(db, {</span>
|
|
775
|
-
type:
|
|
787
|
+
type: Config.GOOGLE,
|
|
776
788
|
workspace: ctx.query.workspace,
|
|
777
789
|
})
|
|
778
790
|
let callbackUrl = <span class="cstat-no" title="statement not covered" >await exports.googleCallbackUrl(config)</span>
|
|
@@ -790,10 +802,10 @@ export const googlePreAuth = <span class="fstat-no" title="function not covered"
|
|
|
790
802
|
}
|
|
791
803
|
|
|
792
804
|
export const googleAuth = <span class="fstat-no" title="function not covered" >async (c</span>tx: any, next: any) =><span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > {</span></span>
|
|
793
|
-
const db = <span class="cstat-no" title="statement not covered" >getGlobalDB()</span>
|
|
805
|
+
const db = <span class="cstat-no" title="statement not covered" >tenancy.getGlobalDB()</span>
|
|
794
806
|
|
|
795
807
|
const config = <span class="cstat-no" title="statement not covered" >await core.db.getScopedConfig(db, {</span>
|
|
796
|
-
type:
|
|
808
|
+
type: Config.GOOGLE,
|
|
797
809
|
workspace: ctx.query.workspace,
|
|
798
810
|
})
|
|
799
811
|
const callbackUrl = <span class="cstat-no" title="statement not covered" >await exports.googleCallbackUrl(config)</span>
|
|
@@ -817,9 +829,9 @@ export const googleAuth = <span class="fstat-no" title="function not covered" >a
|
|
|
817
829
|
}
|
|
818
830
|
|
|
819
831
|
export const oidcStrategyFactory = async (ctx: any, configId: any) => {
|
|
820
|
-
const db = getGlobalDB()
|
|
832
|
+
const db = tenancy.getGlobalDB()
|
|
821
833
|
const config = await core.db.getScopedConfig(db, {
|
|
822
|
-
type:
|
|
834
|
+
type: Config.OIDC,
|
|
823
835
|
group: ctx.query.group,
|
|
824
836
|
})
|
|
825
837
|
|
|
@@ -842,11 +854,11 @@ export const oidcPreAuth = async (ctx: any, next: any) => {
|
|
|
842
854
|
const { configId } = ctx.params
|
|
843
855
|
const strategy = await oidcStrategyFactory(ctx, configId)
|
|
844
856
|
|
|
845
|
-
setCookie(ctx, configId,
|
|
857
|
+
setCookie(ctx, configId, Cookie.OIDC_CONFIG)
|
|
846
858
|
|
|
847
|
-
const db = getGlobalDB()
|
|
859
|
+
const db = tenancy.getGlobalDB()
|
|
848
860
|
const config = await core.db.getScopedConfig(db, {
|
|
849
|
-
type:
|
|
861
|
+
type: Config.OIDC,
|
|
850
862
|
group: ctx.query.group,
|
|
851
863
|
})
|
|
852
864
|
|
|
@@ -864,18 +876,18 @@ export const oidcPreAuth = async (ctx: any, next: any) => {
|
|
|
864
876
|
}
|
|
865
877
|
|
|
866
878
|
export const oidcAuth = async (ctx: any, next: any) => {
|
|
867
|
-
const configId = getCookie(ctx,
|
|
879
|
+
const configId = getCookie(ctx, Cookie.OIDC_CONFIG)
|
|
868
880
|
const strategy = await oidcStrategyFactory(ctx, configId)
|
|
869
881
|
|
|
870
882
|
return passport.authenticate(
|
|
871
883
|
strategy,
|
|
872
884
|
{ successRedirect: "/", failureRedirect: "/error" },
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
885
|
+
async (err: any, user: any, info: any) => {
|
|
886
|
+
await authInternal(ctx, user, err, info)
|
|
887
|
+
await context.identity.doInUserContext(user, async () => {
|
|
888
|
+
await events.auth.login("oidc")
|
|
877
889
|
})
|
|
878
|
-
|
|
890
|
+
ctx.redirect("/")
|
|
879
891
|
}
|
|
880
892
|
)(ctx, next)
|
|
881
893
|
}
|
|
@@ -886,7 +898,7 @@ export const oidcAuth = async (ctx: any, next: any) => {
|
|
|
886
898
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
887
899
|
Code coverage generated by
|
|
888
900
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
889
|
-
at
|
|
901
|
+
at Thu Nov 17 2022 16:59:05 GMT+0000 (Coordinated Universal Time)
|
|
890
902
|
</div>
|
|
891
903
|
<script src="../../../../prettify.js"></script>
|
|
892
904
|
<script>
|