@budibase/worker 3.13.26 → 3.13.28
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 +2 -2
- package/src/api/controllers/global/configs.ts +24 -1
- package/src/api/controllers/global/license.ts +10 -0
- package/src/api/controllers/global/users.ts +0 -9
- package/src/api/routes/global/configs.ts +9 -1
- package/src/api/routes/global/license.ts +1 -0
- package/src/sdk/tenants/tenants.ts +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.13.
|
|
4
|
+
"version": "3.13.28",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "de8a462d540b26a2040f4c8059d0a2395234c628"
|
|
118
118
|
}
|
|
@@ -2,6 +2,8 @@ import * as email from "../../../utilities/email"
|
|
|
2
2
|
import env from "../../../environment"
|
|
3
3
|
import * as auth from "./auth"
|
|
4
4
|
import {
|
|
5
|
+
BadRequestError,
|
|
6
|
+
ForbiddenError,
|
|
5
7
|
cache,
|
|
6
8
|
configs,
|
|
7
9
|
db as dbCore,
|
|
@@ -9,7 +11,6 @@ import {
|
|
|
9
11
|
events,
|
|
10
12
|
objectStore,
|
|
11
13
|
tenancy,
|
|
12
|
-
BadRequestError,
|
|
13
14
|
} from "@budibase/backend-core"
|
|
14
15
|
import { checkAnyUserExists } from "../../../utilities/users"
|
|
15
16
|
import {
|
|
@@ -26,11 +27,13 @@ import {
|
|
|
26
27
|
isAIConfig,
|
|
27
28
|
isGoogleConfig,
|
|
28
29
|
isOIDCConfig,
|
|
30
|
+
isRecaptchaConfig,
|
|
29
31
|
isSettingsConfig,
|
|
30
32
|
isSMTPConfig,
|
|
31
33
|
OIDCConfigs,
|
|
32
34
|
OIDCLogosConfig,
|
|
33
35
|
PASSWORD_REPLACEMENT,
|
|
36
|
+
RecaptchaInnerConfig,
|
|
34
37
|
SaveConfigRequest,
|
|
35
38
|
SaveConfigResponse,
|
|
36
39
|
SettingsBrandingConfig,
|
|
@@ -273,6 +276,21 @@ export async function processAIConfig(
|
|
|
273
276
|
}
|
|
274
277
|
}
|
|
275
278
|
|
|
279
|
+
export async function processRecaptchaConfig(
|
|
280
|
+
config: RecaptchaInnerConfig,
|
|
281
|
+
existingConfig?: RecaptchaInnerConfig
|
|
282
|
+
) {
|
|
283
|
+
if (!(await pro.features.isRecaptchaEnabled())) {
|
|
284
|
+
throw new ForbiddenError("License does not allow use of recaptcha")
|
|
285
|
+
}
|
|
286
|
+
if (config.secretKey === PASSWORD_REPLACEMENT && !existingConfig) {
|
|
287
|
+
throw new BadRequestError("No secret key provided")
|
|
288
|
+
}
|
|
289
|
+
if (config.secretKey === PASSWORD_REPLACEMENT && existingConfig) {
|
|
290
|
+
config.secretKey = existingConfig.secretKey
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
276
294
|
export async function save(
|
|
277
295
|
ctx: UserCtx<SaveConfigRequest, SaveConfigResponse>
|
|
278
296
|
) {
|
|
@@ -306,6 +324,9 @@ export async function save(
|
|
|
306
324
|
await processAIConfig(config, existingConfig.config)
|
|
307
325
|
}
|
|
308
326
|
break
|
|
327
|
+
case ConfigType.RECAPTCHA:
|
|
328
|
+
await processRecaptchaConfig(config, existingConfig?.config)
|
|
329
|
+
break
|
|
309
330
|
}
|
|
310
331
|
} catch (err: any) {
|
|
311
332
|
ctx.throw(400, err)
|
|
@@ -430,6 +451,8 @@ function stripSecrets(config: Config) {
|
|
|
430
451
|
for (const c of config.config.configs) {
|
|
431
452
|
c.clientSecret = PASSWORD_REPLACEMENT
|
|
432
453
|
}
|
|
454
|
+
} else if (isRecaptchaConfig(config)) {
|
|
455
|
+
config.config.secretKey = PASSWORD_REPLACEMENT
|
|
433
456
|
}
|
|
434
457
|
}
|
|
435
458
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ActivateLicenseKeyResponse,
|
|
5
5
|
ActivateOfflineLicenseTokenRequest,
|
|
6
6
|
ActivateOfflineLicenseTokenResponse,
|
|
7
|
+
GetInstallInfo,
|
|
7
8
|
GetLicenseKeyResponse,
|
|
8
9
|
GetOfflineIdentifierResponse,
|
|
9
10
|
GetOfflineLicenseTokenResponse,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
RefreshOfflineLicenseResponse,
|
|
12
13
|
UserCtx,
|
|
13
14
|
} from "@budibase/types"
|
|
15
|
+
import { installation } from "@budibase/backend-core"
|
|
14
16
|
|
|
15
17
|
// LICENSE KEY
|
|
16
18
|
|
|
@@ -94,3 +96,11 @@ export const getQuotaUsage = async (
|
|
|
94
96
|
) => {
|
|
95
97
|
ctx.body = await quotas.getQuotaUsage()
|
|
96
98
|
}
|
|
99
|
+
|
|
100
|
+
export const getInstallInfo = async (ctx: UserCtx<void, GetInstallInfo>) => {
|
|
101
|
+
const install = await installation.getInstall()
|
|
102
|
+
ctx.body = {
|
|
103
|
+
installId: install.installId,
|
|
104
|
+
version: install.version,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -214,15 +214,6 @@ export const adminUser = async (
|
|
|
214
214
|
const { email, password, tenantId, ssoId, givenName, familyName } =
|
|
215
215
|
ctx.request.body
|
|
216
216
|
|
|
217
|
-
if (await platform.tenants.exists(tenantId)) {
|
|
218
|
-
ctx.throw(403, "Organisation already exists.")
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (env.MULTI_TENANCY) {
|
|
222
|
-
// store the new tenant record in the platform db
|
|
223
|
-
await platform.tenants.addTenant(tenantId)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
217
|
await tenancy.doInTenant(tenantId, async () => {
|
|
227
218
|
// account portal sends a pre-hashed password - honour param to prevent double hashing
|
|
228
219
|
const hashPassword = parseBooleanParam(ctx.request.query.hashPassword)
|
|
@@ -79,6 +79,13 @@ function aiValidation() {
|
|
|
79
79
|
)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
function recaptchaValidation() {
|
|
83
|
+
return Joi.object({
|
|
84
|
+
siteKey: Joi.string().required(),
|
|
85
|
+
secretKey: Joi.string().required(),
|
|
86
|
+
}).required()
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
function buildConfigSaveValidation() {
|
|
83
90
|
// prettier-ignore
|
|
84
91
|
return auth.joiValidator.body(Joi.object({
|
|
@@ -97,7 +104,8 @@ function buildConfigSaveValidation() {
|
|
|
97
104
|
{ is: ConfigType.GOOGLE, then: googleValidation() },
|
|
98
105
|
{ is: ConfigType.OIDC, then: oidcValidation() },
|
|
99
106
|
{ is: ConfigType.SCIM, then: scimValidation() },
|
|
100
|
-
{ is: ConfigType.AI, then: aiValidation() }
|
|
107
|
+
{ is: ConfigType.AI, then: aiValidation() },
|
|
108
|
+
{ is: ConfigType.RECAPTCHA, then: recaptchaValidation() },
|
|
101
109
|
],
|
|
102
110
|
}),
|
|
103
111
|
}).required().unknown(true),
|
|
@@ -18,6 +18,7 @@ const activateOfflineLicenseValidator = middleware.joiValidator.body(
|
|
|
18
18
|
loggedInRoutes
|
|
19
19
|
.post("/api/global/license/refresh", controller.refresh)
|
|
20
20
|
.get("/api/global/license/usage", controller.getQuotaUsage)
|
|
21
|
+
.get("/api/global/install", controller.getInstallInfo)
|
|
21
22
|
// LICENSE KEY
|
|
22
23
|
.post(
|
|
23
24
|
"/api/global/license/key",
|
|
@@ -4,7 +4,6 @@ import { quotas } from "@budibase/pro"
|
|
|
4
4
|
|
|
5
5
|
export async function deleteTenant(tenantId: string) {
|
|
6
6
|
await quotas.bustCache()
|
|
7
|
-
await platform.tenants.removeTenant(tenantId)
|
|
8
7
|
await removeTenantUsers(tenantId)
|
|
9
8
|
await removeTenantApps(tenantId)
|
|
10
9
|
await removeGlobalDB(tenantId)
|