@budibase/worker 2.5.9 → 2.5.10-alpha.0
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/package.json +9 -8
- package/scripts/dev/manage.js +1 -0
- package/src/api/controllers/global/users.ts +7 -4
- package/src/api/controllers/system/accounts.ts +2 -2
- package/src/api/index.ts +1 -1
- package/src/api/routes/global/configs.ts +9 -1
- package/src/api/routes/global/tests/scim.spec.ts +1029 -0
- package/src/api/routes/global/tests/users.spec.ts +10 -4
- package/src/api/routes/index.ts +4 -6
- package/src/constants/templates/core.hbs +2 -1
- package/src/environment.ts +0 -1
- package/src/index.ts +7 -7
- package/src/initPro.ts +13 -0
- package/src/middleware/handleScimBody.ts +12 -0
- package/src/sdk/accounts/metadata.ts +11 -2
- package/src/sdk/users/users.ts +101 -135
- package/src/tests/TestConfiguration.ts +50 -1
- package/src/tests/api/index.ts +7 -0
- package/src/tests/api/scim/groups.ts +101 -0
- package/src/tests/api/scim/shared.ts +44 -0
- package/src/tests/api/scim/users.ts +94 -0
- package/src/tests/jestEnv.ts +0 -1
- package/src/tests/jestSetup.ts +0 -2
- package/src/utilities/email.ts +2 -2
- package/tsconfig.json +3 -8
- package/src/elasticApm.ts +0 -10
- package/src/tests/logging.ts +0 -34
- package/src/utilities/appService.ts +0 -46
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.10-alpha.0",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
|
23
23
|
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
|
24
24
|
"dev:builder": "npm run dev:stack:init && nodemon",
|
|
25
|
+
"dev:built": "yarn run dev:stack:init && yarn run run:docker",
|
|
25
26
|
"test": "bash scripts/test.sh",
|
|
26
27
|
"test:watch": "jest --watch",
|
|
27
28
|
"env:multi:enable": "node scripts/multiTenancy.js enable",
|
|
@@ -36,10 +37,10 @@
|
|
|
36
37
|
"author": "Budibase",
|
|
37
38
|
"license": "GPL-3.0",
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@budibase/backend-core": "
|
|
40
|
-
"@budibase/pro": "2.5.
|
|
41
|
-
"@budibase/string-templates": "
|
|
42
|
-
"@budibase/types": "
|
|
40
|
+
"@budibase/backend-core": "2.5.10-alpha.0",
|
|
41
|
+
"@budibase/pro": "2.5.9",
|
|
42
|
+
"@budibase/string-templates": "2.5.10-alpha.0",
|
|
43
|
+
"@budibase/types": "2.5.10-alpha.0",
|
|
43
44
|
"@koa/router": "8.0.8",
|
|
44
45
|
"@sentry/node": "6.17.7",
|
|
45
46
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
"koa-body": "4.2.0",
|
|
57
58
|
"koa-compress": "4.0.1",
|
|
58
59
|
"koa-passport": "4.1.4",
|
|
59
|
-
"koa-pino-logger": "3.0.0",
|
|
60
60
|
"koa-send": "5.0.1",
|
|
61
61
|
"koa-session": "5.13.1",
|
|
62
62
|
"koa-static": "5.0.0",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"passport-google-oauth": "2.0.0",
|
|
67
67
|
"passport-jwt": "4.0.0",
|
|
68
68
|
"passport-local": "1.0.0",
|
|
69
|
-
"pino-pretty": "4.8.0",
|
|
70
69
|
"pouchdb": "7.3.0",
|
|
71
70
|
"pouchdb-all-dbs": "1.1.1",
|
|
72
71
|
"server-destroy": "1.0.1"
|
|
@@ -79,6 +78,7 @@
|
|
|
79
78
|
"@types/jsonwebtoken": "8.5.1",
|
|
80
79
|
"@types/koa": "2.13.4",
|
|
81
80
|
"@types/koa__router": "8.0.8",
|
|
81
|
+
"@types/lodash": "^4.14.191",
|
|
82
82
|
"@types/node": "14.18.20",
|
|
83
83
|
"@types/node-fetch": "2.6.1",
|
|
84
84
|
"@types/pouchdb": "6.4.0",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"copyfiles": "2.4.1",
|
|
90
90
|
"eslint": "6.8.0",
|
|
91
91
|
"jest": "28.1.1",
|
|
92
|
+
"lodash": "4.17.21",
|
|
92
93
|
"nodemon": "2.0.15",
|
|
93
94
|
"pouchdb-adapter-memory": "7.2.2",
|
|
94
95
|
"prettier": "2.3.1",
|
|
@@ -101,5 +102,5 @@
|
|
|
101
102
|
"typescript": "4.7.3",
|
|
102
103
|
"update-dotenv": "1.1.1"
|
|
103
104
|
},
|
|
104
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "1d50b1f07c1a77b21d9757534c353631ce3314f8"
|
|
105
106
|
}
|
package/scripts/dev/manage.js
CHANGED
|
@@ -177,7 +177,7 @@ export const destroy = async (ctx: any) => {
|
|
|
177
177
|
ctx.throw(400, "Unable to delete self.")
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
await userSdk.destroy(id
|
|
180
|
+
await userSdk.destroy(id)
|
|
181
181
|
|
|
182
182
|
ctx.body = {
|
|
183
183
|
message: `User ${id} deleted.`,
|
|
@@ -197,7 +197,7 @@ export const search = async (ctx: any) => {
|
|
|
197
197
|
if (body.paginated === false) {
|
|
198
198
|
await getAppUsers(ctx)
|
|
199
199
|
} else {
|
|
200
|
-
const paginated = await userSdk.paginatedUsers(body)
|
|
200
|
+
const paginated = await userSdk.core.paginatedUsers(body)
|
|
201
201
|
// user hashed password shouldn't ever be returned
|
|
202
202
|
for (let user of paginated.data) {
|
|
203
203
|
if (user) {
|
|
@@ -329,6 +329,7 @@ export const checkInvite = async (ctx: any) => {
|
|
|
329
329
|
try {
|
|
330
330
|
invite = await checkInviteCode(code, false)
|
|
331
331
|
} catch (e) {
|
|
332
|
+
console.warn("Error getting invite from code", e)
|
|
332
333
|
ctx.throw(400, "There was a problem with the invite")
|
|
333
334
|
}
|
|
334
335
|
ctx.body = {
|
|
@@ -415,15 +416,17 @@ export const inviteAccept = async (
|
|
|
415
416
|
})
|
|
416
417
|
|
|
417
418
|
ctx.body = {
|
|
418
|
-
_id: user._id
|
|
419
|
-
_rev: user._rev
|
|
419
|
+
_id: user._id!,
|
|
420
|
+
_rev: user._rev!,
|
|
420
421
|
email: user.email,
|
|
421
422
|
}
|
|
422
423
|
} catch (err: any) {
|
|
423
424
|
if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
|
|
424
425
|
// explicitly re-throw limit exceeded errors
|
|
425
426
|
ctx.throw(400, err)
|
|
427
|
+
return
|
|
426
428
|
}
|
|
429
|
+
console.warn("Error inviting user", err)
|
|
427
430
|
ctx.throw(400, "Unable to create new user, invitation invalid.")
|
|
428
431
|
}
|
|
429
432
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Account, AccountMetadata } from "@budibase/types"
|
|
1
|
+
import { Account, AccountMetadata, Ctx } from "@budibase/types"
|
|
2
2
|
import * as accounts from "../../../sdk/accounts"
|
|
3
3
|
|
|
4
|
-
export const save = async (ctx:
|
|
4
|
+
export const save = async (ctx: Ctx<Account, AccountMetadata>) => {
|
|
5
5
|
const account = ctx.request.body as Account
|
|
6
6
|
let metadata: AccountMetadata = {
|
|
7
7
|
_id: accounts.metadata.formatAccountMetadataId(account.accountId),
|
package/src/api/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Router from "@koa/router"
|
|
2
2
|
const compress = require("koa-compress")
|
|
3
|
-
|
|
3
|
+
import zlib from "zlib"
|
|
4
4
|
import { routes } from "./routes"
|
|
5
5
|
import { middleware as pro } from "@budibase/pro"
|
|
6
6
|
import { auth, middleware } from "@budibase/backend-core"
|
|
@@ -58,6 +58,13 @@ function oidcValidation() {
|
|
|
58
58
|
}).unknown(true)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
function scimValidation() {
|
|
62
|
+
// prettier-ignore
|
|
63
|
+
return Joi.object({
|
|
64
|
+
enabled: Joi.boolean().required(),
|
|
65
|
+
}).unknown(true)
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
function buildConfigSaveValidation() {
|
|
62
69
|
// prettier-ignore
|
|
63
70
|
return auth.joiValidator.body(Joi.object({
|
|
@@ -74,7 +81,8 @@ function buildConfigSaveValidation() {
|
|
|
74
81
|
{ is: ConfigType.SETTINGS, then: settingValidation() },
|
|
75
82
|
{ is: ConfigType.ACCOUNT, then: Joi.object().unknown(true) },
|
|
76
83
|
{ is: ConfigType.GOOGLE, then: googleValidation() },
|
|
77
|
-
{ is: ConfigType.OIDC, then: oidcValidation() }
|
|
84
|
+
{ is: ConfigType.OIDC, then: oidcValidation() },
|
|
85
|
+
{ is: ConfigType.SCIM, then: scimValidation() }
|
|
78
86
|
],
|
|
79
87
|
}),
|
|
80
88
|
}).required().unknown(true),
|