@budibase/worker 2.13.51 → 2.13.52
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.52",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "Budibase",
|
|
38
38
|
"license": "GPL-3.0",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@budibase/backend-core": "2.13.
|
|
41
|
-
"@budibase/pro": "2.13.
|
|
42
|
-
"@budibase/string-templates": "2.13.
|
|
43
|
-
"@budibase/types": "2.13.
|
|
40
|
+
"@budibase/backend-core": "2.13.52",
|
|
41
|
+
"@budibase/pro": "2.13.52",
|
|
42
|
+
"@budibase/string-templates": "2.13.52",
|
|
43
|
+
"@budibase/types": "2.13.52",
|
|
44
44
|
"@koa/router": "8.0.8",
|
|
45
45
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
46
46
|
"@types/global-agent": "2.1.1",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "7afc8a9d0ca42fdb13b6146f7bb93ecf18023d15"
|
|
111
111
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import tk from "timekeeper"
|
|
2
2
|
import _ from "lodash"
|
|
3
|
-
import { mocks, structures } from "@budibase/backend-core/tests"
|
|
3
|
+
import { generator, mocks, structures } from "@budibase/backend-core/tests"
|
|
4
4
|
import {
|
|
5
5
|
ScimCreateUserRequest,
|
|
6
6
|
ScimGroupResponse,
|
|
@@ -14,9 +14,14 @@ import { events } from "@budibase/backend-core"
|
|
|
14
14
|
jest.retryTimes(2, { logErrorsBeforeRetry: true })
|
|
15
15
|
jest.setTimeout(30000)
|
|
16
16
|
|
|
17
|
-
mocks.licenses.useScimIntegration()
|
|
18
|
-
|
|
19
17
|
describe("scim", () => {
|
|
18
|
+
beforeAll(async () => {
|
|
19
|
+
tk.freeze(mocks.date.MOCK_DATE)
|
|
20
|
+
mocks.licenses.useScimIntegration()
|
|
21
|
+
|
|
22
|
+
await config.setSCIMConfig(true)
|
|
23
|
+
})
|
|
24
|
+
|
|
20
25
|
beforeEach(async () => {
|
|
21
26
|
jest.resetAllMocks()
|
|
22
27
|
tk.freeze(mocks.date.MOCK_DATE)
|
|
@@ -570,8 +575,15 @@ describe("scim", () => {
|
|
|
570
575
|
beforeAll(async () => {
|
|
571
576
|
groups = []
|
|
572
577
|
|
|
573
|
-
|
|
574
|
-
|
|
578
|
+
const groupNames = generator.unique(
|
|
579
|
+
() => generator.word(),
|
|
580
|
+
groupCount
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
for (const groupName of groupNames) {
|
|
584
|
+
const body = structures.scim.createGroupRequest({
|
|
585
|
+
displayName: groupName,
|
|
586
|
+
})
|
|
575
587
|
groups.push(await config.api.scimGroupsAPI.post({ body }))
|
|
576
588
|
}
|
|
577
589
|
|
package/src/sdk/auth/auth.ts
CHANGED
|
@@ -79,6 +79,9 @@ export const resetUpdate = async (resetCode: string, password: string) => {
|
|
|
79
79
|
user.password = password
|
|
80
80
|
user = await userSdk.db.save(user)
|
|
81
81
|
|
|
82
|
+
await cache.passwordReset.invalidateCode(resetCode)
|
|
83
|
+
await sessions.invalidateSessions(userId)
|
|
84
|
+
|
|
82
85
|
// remove password from the user before sending events
|
|
83
86
|
delete user.password
|
|
84
87
|
await events.user.passwordReset(user)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { cache, context, sessions, utils } from "@budibase/backend-core"
|
|
2
|
+
import { loginUser, resetUpdate } from "../auth"
|
|
3
|
+
import { generator, structures } from "@budibase/backend-core/tests"
|
|
4
|
+
import { TestConfiguration } from "../../../tests"
|
|
5
|
+
|
|
6
|
+
describe("auth", () => {
|
|
7
|
+
const config = new TestConfiguration()
|
|
8
|
+
|
|
9
|
+
describe("resetUpdate", () => {
|
|
10
|
+
it("providing a valid code will update the password", async () => {
|
|
11
|
+
await context.doInTenant(structures.tenant.id(), async () => {
|
|
12
|
+
const user = await config.createUser()
|
|
13
|
+
const previousPassword = user.password
|
|
14
|
+
|
|
15
|
+
const code = await cache.passwordReset.createCode(user._id!, {})
|
|
16
|
+
const newPassword = generator.hash()
|
|
17
|
+
|
|
18
|
+
await resetUpdate(code, newPassword)
|
|
19
|
+
|
|
20
|
+
const persistedUser = await config.getUser(user.email)
|
|
21
|
+
expect(persistedUser.password).not.toBe(previousPassword)
|
|
22
|
+
expect(
|
|
23
|
+
await utils.compare(newPassword, persistedUser.password!)
|
|
24
|
+
).toBeTruthy()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("wrong code will not allow to reset the password", async () => {
|
|
29
|
+
await context.doInTenant(structures.tenant.id(), async () => {
|
|
30
|
+
const code = generator.hash()
|
|
31
|
+
const newPassword = generator.hash()
|
|
32
|
+
|
|
33
|
+
await expect(resetUpdate(code, newPassword)).rejects.toThrow(
|
|
34
|
+
"Provided information is not valid, cannot reset password - please try again."
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it("the same code cannot be used twice", async () => {
|
|
40
|
+
await context.doInTenant(structures.tenant.id(), async () => {
|
|
41
|
+
const user = await config.createUser()
|
|
42
|
+
|
|
43
|
+
const code = await cache.passwordReset.createCode(user._id!, {})
|
|
44
|
+
const newPassword = generator.hash()
|
|
45
|
+
|
|
46
|
+
await resetUpdate(code, newPassword)
|
|
47
|
+
await expect(resetUpdate(code, newPassword)).rejects.toThrow(
|
|
48
|
+
"Provided information is not valid, cannot reset password - please try again."
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it("updating the password will invalidate all the sessions", async () => {
|
|
54
|
+
await context.doInTenant(structures.tenant.id(), async () => {
|
|
55
|
+
const user = await config.createUser()
|
|
56
|
+
|
|
57
|
+
await loginUser(user)
|
|
58
|
+
|
|
59
|
+
expect(await sessions.getSessionsForUser(user._id!)).toHaveLength(1)
|
|
60
|
+
|
|
61
|
+
const code = await cache.passwordReset.createCode(user._id!, {})
|
|
62
|
+
const newPassword = generator.hash()
|
|
63
|
+
|
|
64
|
+
await resetUpdate(code, newPassword)
|
|
65
|
+
|
|
66
|
+
expect(await sessions.getSessionsForUser(user._id!)).toHaveLength(0)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|