@budibase/backend-core 2.10.13 → 2.10.14
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/dist/index.js +32 -9
- package/dist/index.js.map +2 -2
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/constants/db.d.ts +1 -1
- package/dist/src/constants/db.js +1 -1
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/db/views.js +4 -0
- package/dist/src/db/views.js.map +1 -1
- package/dist/src/platform/users.d.ts +1 -1
- package/dist/src/platform/users.js +15 -3
- package/dist/src/platform/users.js.map +1 -1
- package/dist/src/users/db.js +1 -1
- package/dist/src/users/db.js.map +1 -1
- package/dist/tests/core/utilities/structures/accounts.d.ts +3 -1
- package/dist/tests/core/utilities/structures/accounts.js +20 -1
- package/dist/tests/core/utilities/structures/accounts.js.map +1 -1
- package/package.json +4 -4
- package/src/constants/db.ts +1 -1
- package/src/db/views.ts +4 -0
- package/src/platform/users.ts +31 -3
- package/src/users/db.ts +6 -1
- package/tests/core/utilities/structures/accounts.ts +34 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.14",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.2",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.10.
|
|
27
|
-
"@budibase/types": "2.10.
|
|
26
|
+
"@budibase/shared-core": "2.10.14",
|
|
27
|
+
"@budibase/types": "2.10.14",
|
|
28
28
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
29
29
|
"aws-cloudfront-sign": "2.2.0",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "ab7ca87cce8a1e9acefb6386486fecefd18a97c1"
|
|
108
108
|
}
|
package/src/constants/db.ts
CHANGED
|
@@ -18,7 +18,7 @@ export enum ViewName {
|
|
|
18
18
|
ROUTING = "screen_routes",
|
|
19
19
|
AUTOMATION_LOGS = "automation_logs",
|
|
20
20
|
ACCOUNT_BY_EMAIL = "account_by_email",
|
|
21
|
-
PLATFORM_USERS_LOWERCASE = "
|
|
21
|
+
PLATFORM_USERS_LOWERCASE = "platform_users_lowercase_2",
|
|
22
22
|
USER_BY_GROUP = "user_by_group",
|
|
23
23
|
APP_BACKUP_BY_TRIGGER = "by_trigger",
|
|
24
24
|
}
|
package/src/db/views.ts
CHANGED
|
@@ -190,6 +190,10 @@ export const createPlatformUserView = async () => {
|
|
|
190
190
|
if (doc.tenantId) {
|
|
191
191
|
emit(doc._id.toLowerCase(), doc._id)
|
|
192
192
|
}
|
|
193
|
+
|
|
194
|
+
if (doc.ssoId) {
|
|
195
|
+
emit(doc.ssoId, doc._id)
|
|
196
|
+
}
|
|
193
197
|
}`
|
|
194
198
|
await createPlatformView(viewJs, ViewName.PLATFORM_USERS_LOWERCASE)
|
|
195
199
|
}
|
package/src/platform/users.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
PlatformUser,
|
|
6
6
|
PlatformUserByEmail,
|
|
7
7
|
PlatformUserById,
|
|
8
|
+
PlatformUserBySsoId,
|
|
8
9
|
User,
|
|
9
10
|
} from "@budibase/types"
|
|
10
11
|
|
|
@@ -45,6 +46,20 @@ function newUserEmailDoc(
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
function newUserSsoIdDoc(
|
|
50
|
+
ssoId: string,
|
|
51
|
+
email: string,
|
|
52
|
+
userId: string,
|
|
53
|
+
tenantId: string
|
|
54
|
+
): PlatformUserBySsoId {
|
|
55
|
+
return {
|
|
56
|
+
_id: ssoId,
|
|
57
|
+
userId,
|
|
58
|
+
email,
|
|
59
|
+
tenantId,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
48
63
|
/**
|
|
49
64
|
* Add a new user id or email doc if it doesn't exist.
|
|
50
65
|
*/
|
|
@@ -64,11 +79,24 @@ async function addUserDoc(emailOrId: string, newDocFn: () => PlatformUser) {
|
|
|
64
79
|
}
|
|
65
80
|
}
|
|
66
81
|
|
|
67
|
-
export async function addUser(
|
|
68
|
-
|
|
82
|
+
export async function addUser(
|
|
83
|
+
tenantId: string,
|
|
84
|
+
userId: string,
|
|
85
|
+
email: string,
|
|
86
|
+
ssoId?: string
|
|
87
|
+
) {
|
|
88
|
+
const promises = [
|
|
69
89
|
addUserDoc(userId, () => newUserIdDoc(userId, tenantId)),
|
|
70
90
|
addUserDoc(email, () => newUserEmailDoc(userId, email, tenantId)),
|
|
71
|
-
]
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
if (ssoId) {
|
|
94
|
+
promises.push(
|
|
95
|
+
addUserDoc(ssoId, () => newUserSsoIdDoc(ssoId, email, userId, tenantId))
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await Promise.all(promises)
|
|
72
100
|
}
|
|
73
101
|
|
|
74
102
|
// DELETE
|
package/src/users/db.ts
CHANGED
|
@@ -278,7 +278,12 @@ export class UserDB {
|
|
|
278
278
|
builtUser._rev = response.rev
|
|
279
279
|
|
|
280
280
|
await eventHelpers.handleSaveEvents(builtUser, dbUser)
|
|
281
|
-
await platform.users.addUser(
|
|
281
|
+
await platform.users.addUser(
|
|
282
|
+
tenantId,
|
|
283
|
+
builtUser._id!,
|
|
284
|
+
builtUser.email,
|
|
285
|
+
builtUser.ssoId
|
|
286
|
+
)
|
|
282
287
|
await cache.user.invalidateUser(response.id)
|
|
283
288
|
|
|
284
289
|
await Promise.all(groupPromises)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generator,
|
|
1
|
+
import { generator, quotas, uuid } from "."
|
|
2
2
|
import { generateGlobalUserID } from "../../../../src/docIds"
|
|
3
3
|
import {
|
|
4
4
|
Account,
|
|
@@ -6,10 +6,11 @@ import {
|
|
|
6
6
|
AccountSSOProviderType,
|
|
7
7
|
AuthType,
|
|
8
8
|
CloudAccount,
|
|
9
|
-
Hosting,
|
|
10
|
-
SSOAccount,
|
|
11
9
|
CreateAccount,
|
|
12
10
|
CreatePassswordAccount,
|
|
11
|
+
CreateVerifiableSSOAccount,
|
|
12
|
+
Hosting,
|
|
13
|
+
SSOAccount,
|
|
13
14
|
} from "@budibase/types"
|
|
14
15
|
import sample from "lodash/sample"
|
|
15
16
|
|
|
@@ -68,6 +69,23 @@ export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
export function verifiableSsoAccount(
|
|
73
|
+
account: Account = cloudAccount()
|
|
74
|
+
): SSOAccount {
|
|
75
|
+
return {
|
|
76
|
+
...account,
|
|
77
|
+
authType: AuthType.SSO,
|
|
78
|
+
oauth2: {
|
|
79
|
+
accessToken: generator.string(),
|
|
80
|
+
refreshToken: generator.string(),
|
|
81
|
+
},
|
|
82
|
+
pictureUrl: generator.url(),
|
|
83
|
+
provider: AccountSSOProvider.MICROSOFT,
|
|
84
|
+
providerType: AccountSSOProviderType.MICROSOFT,
|
|
85
|
+
thirdPartyProfile: { id: "abc123" },
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
71
89
|
export const cloudCreateAccount: CreatePassswordAccount = {
|
|
72
90
|
email: "cloud@budibase.com",
|
|
73
91
|
tenantId: "cloud",
|
|
@@ -91,6 +109,19 @@ export const cloudSSOCreateAccount: CreateAccount = {
|
|
|
91
109
|
profession: "Software Engineer",
|
|
92
110
|
}
|
|
93
111
|
|
|
112
|
+
export const cloudVerifiableSSOCreateAccount: CreateVerifiableSSOAccount = {
|
|
113
|
+
email: "cloud-sso@budibase.com",
|
|
114
|
+
tenantId: "cloud-sso",
|
|
115
|
+
hosting: Hosting.CLOUD,
|
|
116
|
+
authType: AuthType.SSO,
|
|
117
|
+
tenantName: "cloudsso",
|
|
118
|
+
name: "Budi Armstrong",
|
|
119
|
+
size: "10+",
|
|
120
|
+
profession: "Software Engineer",
|
|
121
|
+
provider: AccountSSOProvider.MICROSOFT,
|
|
122
|
+
thirdPartyProfile: { id: "abc123" },
|
|
123
|
+
}
|
|
124
|
+
|
|
94
125
|
export const selfCreateAccount: CreatePassswordAccount = {
|
|
95
126
|
email: "self@budibase.com",
|
|
96
127
|
tenantId: "self",
|