1
0
Fork 0
mirror of synced 2024-10-03 10:36:59 +13:00

Merge remote-tracking branch 'origin/develop' into feature/whitelabelling

This commit is contained in:
Dean 2023-03-20 09:07:19 +00:00
commit 5e84020849
17 changed files with 103 additions and 83 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -24,7 +24,7 @@
"dependencies": {
"@budibase/nano": "10.1.2",
"@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "2.4.27-alpha.3",
"@budibase/types": "2.4.27-alpha.4",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",

View file

@ -16,6 +16,7 @@ export abstract class BudibaseError extends Error {
export enum ErrorCode {
USAGE_LIMIT_EXCEEDED = "usage_limit_exceeded",
FEATURE_DISABLED = "feature_disabled",
INVALID_API_KEY = "invalid_api_key",
HTTP = "http",
}
@ -85,3 +86,14 @@ export class FeatureDisabledError extends HTTPError {
}
}
}
// AUTH
export class InvalidAPIKeyError extends BudibaseError {
constructor() {
super(
"Invalid API key - may need re-generated, or user doesn't exist",
ErrorCode.INVALID_API_KEY
)
}
}

View file

@ -14,6 +14,7 @@ import { decrypt } from "../security/encryption"
import * as identity from "../context/identity"
import env from "../environment"
import { Ctx, EndpointMatcher } from "@budibase/types"
import { InvalidAPIKeyError, ErrorCode } from "../errors"
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
? parseInt(env.SESSION_UPDATE_PERIOD)
@ -48,22 +49,27 @@ async function checkApiKey(apiKey: string, populateUser?: Function) {
const decrypted = decrypt(apiKey)
const tenantId = decrypted.split(SEPARATOR)[0]
return doInTenant(tenantId, async () => {
const db = getGlobalDB()
// api key is encrypted in the database
const userId = (await queryGlobalView(
ViewName.BY_API_KEY,
{
key: apiKey,
},
db
)) as string
let userId
try {
const db = getGlobalDB()
// api key is encrypted in the database
userId = (await queryGlobalView(
ViewName.BY_API_KEY,
{
key: apiKey,
},
db
)) as string
} catch (err) {
userId = undefined
}
if (userId) {
return {
valid: true,
user: await getUser(userId, tenantId, populateUser),
}
} else {
throw "Invalid API key"
throw new InvalidAPIKeyError()
}
})
}
@ -164,8 +170,10 @@ export default function (
console.error(`Auth Error: ${err.message}`)
console.error(err)
// invalid token, clear the cookie
if (err && err.name === "JsonWebTokenError") {
if (err?.name === "JsonWebTokenError") {
clearCookie(ctx, Cookie.Auth)
} else if (err?.code === ErrorCode.INVALID_API_KEY) {
ctx.throw(403, err.message)
}
// allow configuring for public access
if ((opts && opts.publicAllowed) || publicEndpoint) {

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,8 +38,8 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/shared-core": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/shared-core": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -58,11 +58,11 @@
}
},
"dependencies": {
"@budibase/bbui": "2.4.27-alpha.3",
"@budibase/client": "2.4.27-alpha.3",
"@budibase/frontend-core": "2.4.27-alpha.3",
"@budibase/shared-core": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/bbui": "2.4.27-alpha.4",
"@budibase/client": "2.4.27-alpha.4",
"@budibase/frontend-core": "2.4.27-alpha.4",
"@budibase/shared-core": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "dist/index.js",
"bin": {
@ -29,9 +29,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/types": "2.4.27-alpha.3",
"@budibase/backend-core": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@budibase/types": "2.4.27-alpha.4",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,11 +19,11 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "2.4.27-alpha.3",
"@budibase/frontend-core": "2.4.27-alpha.3",
"@budibase/shared-core": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/types": "2.4.27-alpha.3",
"@budibase/bbui": "2.4.27-alpha.4",
"@budibase/frontend-core": "2.4.27-alpha.4",
"@budibase/shared-core": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@budibase/types": "2.4.27-alpha.4",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View file

@ -1,13 +1,13 @@
{
"name": "@budibase/frontend-core",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "2.4.27-alpha.3",
"@budibase/shared-core": "2.4.27-alpha.3",
"@budibase/bbui": "2.4.27-alpha.4",
"@budibase/shared-core": "2.4.27-alpha.4",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/sdk",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase Public API SDK",
"author": "Budibase",
"license": "MPL-2.0",

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -43,12 +43,12 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "2.4.27-alpha.3",
"@budibase/client": "2.4.27-alpha.3",
"@budibase/pro": "2.4.27-alpha.3",
"@budibase/shared-core": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/types": "2.4.27-alpha.3",
"@budibase/backend-core": "2.4.27-alpha.4",
"@budibase/client": "2.4.27-alpha.4",
"@budibase/pro": "2.4.27-alpha.4",
"@budibase/shared-core": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@budibase/types": "2.4.27-alpha.4",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View file

@ -1278,14 +1278,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.3.tgz#c067bf894f90e0f86c85bc4cc711c76974a32be3"
integrity sha512-m8m/lJAB2y36MCE72tRH6O4nAQaECg+9n1W4ozAqtfMWW6JqGLvd4Naxd+LEgO8OOw/vLvzWLbFtek3MasgXCg==
"@budibase/backend-core@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.4.tgz#b603dc15278d63e0af0546637da4182c080dbaac"
integrity sha512-U8S7eDSzm1Lt3b80GwVo2oglgFs08OWK1zPG28Cd556d/YKfbpw2ifDXUYYQkJkmN0j8yoe2547kFGSesfxwCw==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.27-alpha.3"
"@budibase/types" "2.4.27-alpha.4"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -1417,14 +1417,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.3.tgz#c2264116fc5cfbf379d0fb9fae74fb9d8b2a8345"
integrity sha512-/OtPXehLN9DerycSCcnCrtY4hxBp229RGx2sFuu/gy/1xrOcMqcZ2+ZLNFhVR/LFm95JQzpPU0TCsJF0bBj+jQ==
"@budibase/pro@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.4.tgz#69406a5acd8756eea1c929ed5adea2c15e327abe"
integrity sha512-eM2Cozcqm8PQIlMxOHoektr02IkKy2Vi41UvWZwaPmOuWttPIAuk7oU0t9TRe26QEPMgvxKtjXxaKpl0rqVikw==
dependencies:
"@budibase/backend-core" "2.4.27-alpha.3"
"@budibase/backend-core" "2.4.27-alpha.4"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.27-alpha.3"
"@budibase/types" "2.4.27-alpha.4"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -1463,10 +1463,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.3.tgz#1251f2d0a058022fa72bd971ca1017eb0a37253a"
integrity sha512-2xplbfF2RZMrzXnOoXTLJLMGRapYcu7QturO/S7OMz3WXJ8gsd0U0lh/pi7i1L7YEs34xmKLNjmeMGbwozTfPw==
"@budibase/types@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.4.tgz#c04dc2fe410e23c3f1e27d50dda690e3021178f9"
integrity sha512-HZuEVs6kRBHn/ajr3MTz7htFM9okByswQzXhmgC1KdGnaoJOlSTyxOFAaPLrmTJGnTGCbgK486N46cZZFuzzeQ==
"@bull-board/api@3.7.0":
version "3.7.0"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/shared-core",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Shared data utils",
"main": "dist/cjs/src/index.js",
"types": "dist/mjs/src/index.d.ts",
@ -20,7 +20,7 @@
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
},
"dependencies": {
"@budibase/types": "2.4.27-alpha.3"
"@budibase/types": "2.4.27-alpha.4"
},
"devDependencies": {
"concurrently": "^7.6.0",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase types",
"main": "dist/cjs/index.js",
"types": "dist/mjs/index.d.ts",

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "2.4.27-alpha.3",
"version": "2.4.27-alpha.4",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -36,10 +36,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "2.4.27-alpha.3",
"@budibase/pro": "2.4.27-alpha.3",
"@budibase/string-templates": "2.4.27-alpha.3",
"@budibase/types": "2.4.27-alpha.3",
"@budibase/backend-core": "2.4.27-alpha.4",
"@budibase/pro": "2.4.27-alpha.4",
"@budibase/string-templates": "2.4.27-alpha.4",
"@budibase/types": "2.4.27-alpha.4",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View file

@ -475,14 +475,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.3.tgz#c067bf894f90e0f86c85bc4cc711c76974a32be3"
integrity sha512-m8m/lJAB2y36MCE72tRH6O4nAQaECg+9n1W4ozAqtfMWW6JqGLvd4Naxd+LEgO8OOw/vLvzWLbFtek3MasgXCg==
"@budibase/backend-core@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.4.tgz#b603dc15278d63e0af0546637da4182c080dbaac"
integrity sha512-U8S7eDSzm1Lt3b80GwVo2oglgFs08OWK1zPG28Cd556d/YKfbpw2ifDXUYYQkJkmN0j8yoe2547kFGSesfxwCw==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.27-alpha.3"
"@budibase/types" "2.4.27-alpha.4"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -564,14 +564,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.3.tgz#c2264116fc5cfbf379d0fb9fae74fb9d8b2a8345"
integrity sha512-/OtPXehLN9DerycSCcnCrtY4hxBp229RGx2sFuu/gy/1xrOcMqcZ2+ZLNFhVR/LFm95JQzpPU0TCsJF0bBj+jQ==
"@budibase/pro@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.4.tgz#69406a5acd8756eea1c929ed5adea2c15e327abe"
integrity sha512-eM2Cozcqm8PQIlMxOHoektr02IkKy2Vi41UvWZwaPmOuWttPIAuk7oU0t9TRe26QEPMgvxKtjXxaKpl0rqVikw==
dependencies:
"@budibase/backend-core" "2.4.27-alpha.3"
"@budibase/backend-core" "2.4.27-alpha.4"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.27-alpha.3"
"@budibase/types" "2.4.27-alpha.4"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -592,10 +592,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.27-alpha.3":
version "2.4.27-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.3.tgz#1251f2d0a058022fa72bd971ca1017eb0a37253a"
integrity sha512-2xplbfF2RZMrzXnOoXTLJLMGRapYcu7QturO/S7OMz3WXJ8gsd0U0lh/pi7i1L7YEs34xmKLNjmeMGbwozTfPw==
"@budibase/types@2.4.27-alpha.4":
version "2.4.27-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.4.tgz#c04dc2fe410e23c3f1e27d50dda690e3021178f9"
integrity sha512-HZuEVs6kRBHn/ajr3MTz7htFM9okByswQzXhmgC1KdGnaoJOlSTyxOFAaPLrmTJGnTGCbgK486N46cZZFuzzeQ==
"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"