1
0
Fork 0
mirror of synced 2024-08-31 09:41:13 +12:00

Merge branch 'develop' of github.com:Budibase/budibase into spreadsheet-integration

This commit is contained in:
Andrew Kingston 2023-03-31 12:08:58 +01:00
commit b2d2cf3989
62 changed files with 455 additions and 224 deletions

View file

@ -17,6 +17,7 @@ jobs:
id: version id: version
run: | run: |
if [ -z "${{ github.event.inputs.version }}" ]; then if [ -z "${{ github.event.inputs.version }}" ]; then
git pull
release_version=$(cat lerna.json | jq -r '.version') release_version=$(cat lerna.json | jq -r '.version')
else else
release_version=${{ github.event.inputs.version }} release_version=${{ github.event.inputs.version }}

View file

@ -134,6 +134,7 @@ jobs:
- name: Get the latest budibase release version - name: Get the latest budibase release version
id: version id: version
run: | run: |
git pull
release_version=$(cat lerna.json | jq -r '.version') release_version=$(cat lerna.json | jq -r '.version')
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV

View file

@ -212,11 +212,24 @@ spec:
image: budibase/apps:{{ .Values.globals.appVersion }} image: budibase/apps:{{ .Values.globals.appVersion }}
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe: livenessProbe:
httpGet:
path: /health
port: {{ .Values.services.apps.port }}
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
readinessProbe:
httpGet: httpGet:
path: /health path: /health
port: {{ .Values.services.apps.port }} port: {{ .Values.services.apps.port }}
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 5 periodSeconds: 5
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
name: bbapps name: bbapps
ports: ports:
- containerPort: {{ .Values.services.apps.port }} - containerPort: {{ .Values.services.apps.port }}

View file

@ -202,11 +202,23 @@ spec:
image: budibase/worker:{{ .Values.globals.appVersion }} image: budibase/worker:{{ .Values.globals.appVersion }}
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe: livenessProbe:
httpGet:
path: /health
port: {{ .Values.services.worker.port }}
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
readinessProbe:
httpGet: httpGet:
path: /health path: /health
port: {{ .Values.services.worker.port }} port: {{ .Values.services.worker.port }}
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 5 periodSeconds: 5
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
name: bbworker name: bbworker
ports: ports:
- containerPort: {{ .Values.services.worker.port }} - containerPort: {{ .Values.services.worker.port }}

View file

@ -343,6 +343,7 @@ couchdb:
## Configure liveness and readiness probe values ## Configure liveness and readiness probe values
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes ## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes
# FOR COUCHDB
livenessProbe: livenessProbe:
enabled: true enabled: true
failureThreshold: 3 failureThreshold: 3

View file

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

View file

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

View file

@ -199,7 +199,6 @@ export async function platformLogout(opts: PlatformLogoutOpts) {
} else { } else {
// clear cookies // clear cookies
clearCookie(ctx, Cookie.Auth) clearCookie(ctx, Cookie.Auth)
clearCookie(ctx, Cookie.CurrentApp)
} }
const sessionIds = sessions.map(({ sessionId }) => sessionId) const sessionIds = sessions.map(({ sessionId }) => sessionId)

View file

@ -0,0 +1,54 @@
import dns from "dns"
import net from "net"
import env from "../environment"
import { promisify } from "util"
let blackListArray: string[] | undefined
const performLookup = promisify(dns.lookup)
async function lookup(address: string): Promise<string[]> {
if (!net.isIP(address)) {
// need this for URL parsing simply
if (!address.startsWith("http")) {
address = `https://${address}`
}
address = new URL(address).hostname
}
const addresses = await performLookup(address, {
all: true,
})
return addresses.map(addr => addr.address)
}
export async function refreshBlacklist() {
const blacklist = env.BLACKLIST_IPS
const list = blacklist?.split(",") || []
let final: string[] = []
for (let addr of list) {
const trimmed = addr.trim()
if (!net.isIP(trimmed)) {
const addresses = await lookup(trimmed)
final = final.concat(addresses)
} else {
final.push(trimmed)
}
}
blackListArray = final
}
export async function isBlacklisted(address: string): Promise<boolean> {
if (!blackListArray) {
await refreshBlacklist()
}
if (blackListArray?.length === 0) {
return false
}
// no need for DNS
let ips: string[]
if (!net.isIP(address)) {
ips = await lookup(address)
} else {
ips = [address]
}
return !!blackListArray?.find(addr => ips.includes(addr))
}

View file

@ -0,0 +1 @@
export * from "./blacklist"

View file

@ -0,0 +1,46 @@
import { refreshBlacklist, isBlacklisted } from ".."
import env from "../../environment"
describe("blacklist", () => {
beforeAll(async () => {
env._set(
"BLACKLIST_IPS",
"www.google.com,192.168.1.1, 1.1.1.1,2.2.2.2/something"
)
await refreshBlacklist()
})
it("should blacklist 192.168.1.1", async () => {
expect(await isBlacklisted("192.168.1.1")).toBe(true)
})
it("should allow 192.168.1.2", async () => {
expect(await isBlacklisted("192.168.1.2")).toBe(false)
})
it("should blacklist www.google.com", async () => {
expect(await isBlacklisted("www.google.com")).toBe(true)
})
it("should handle a complex domain", async () => {
expect(
await isBlacklisted("https://www.google.com/derp/?something=1")
).toBe(true)
})
it("should allow www.microsoft.com", async () => {
expect(await isBlacklisted("www.microsoft.com")).toBe(false)
})
it("should blacklist an IP that needed trimming", async () => {
expect(await isBlacklisted("1.1.1.1")).toBe(true)
})
it("should blacklist 1.1.1.1/something", async () => {
expect(await isBlacklisted("1.1.1.1/something")).toBe(true)
})
it("should blacklist 2.2.2.2", async () => {
expect(await isBlacklisted("2.2.2.2")).toBe(true)
})
})

View file

@ -1,4 +1,9 @@
import { DBTestConfiguration, generator, testEnv } from "../../../tests" import {
DBTestConfiguration,
generator,
testEnv,
structures,
} from "../../../tests"
import { ConfigType } from "@budibase/types" import { ConfigType } from "@budibase/types"
import env from "../../environment" import env from "../../environment"
import * as configs from "../configs" import * as configs from "../configs"
@ -113,4 +118,71 @@ describe("configs", () => {
}) })
}) })
}) })
describe("getGoogleDatasourceConfig", () => {
function setEnvVars() {
env.GOOGLE_CLIENT_SECRET = "test"
env.GOOGLE_CLIENT_ID = "test"
}
function unsetEnvVars() {
env.GOOGLE_CLIENT_SECRET = undefined
env.GOOGLE_CLIENT_ID = undefined
}
describe("cloud", () => {
beforeEach(() => {
testEnv.cloudHosted()
})
it("returns from env vars", async () => {
await config.doInTenant(async () => {
setEnvVars()
const config = await configs.getGoogleDatasourceConfig()
unsetEnvVars()
expect(config).toEqual({
activated: true,
clientID: "test",
clientSecret: "test",
})
})
})
it("returns undefined when no env vars are configured", async () => {
await config.doInTenant(async () => {
const config = await configs.getGoogleDatasourceConfig()
expect(config).toBeUndefined()
})
})
})
describe("self host", () => {
beforeEach(() => {
testEnv.selfHosted()
})
it("returns from config", async () => {
await config.doInTenant(async () => {
const googleDoc = structures.sso.googleConfigDoc()
await configs.save(googleDoc)
const config = await configs.getGoogleDatasourceConfig()
expect(config).toEqual(googleDoc.config)
})
})
it("falls back to env vars when config is disabled", async () => {
await config.doInTenant(async () => {
setEnvVars()
const config = await configs.getGoogleDatasourceConfig()
unsetEnvVars()
expect(config).toEqual({
activated: true,
clientID: "test",
clientSecret: "test",
})
})
})
})
})
}) })

View file

@ -4,7 +4,6 @@ export enum UserStatus {
} }
export enum Cookie { export enum Cookie {
CurrentApp = "budibase:currentapp",
Auth = "budibase:auth", Auth = "budibase:auth",
Init = "budibase:init", Init = "budibase:init",
ACCOUNT_RETURN_URL = "budibase:account:returnurl", ACCOUNT_RETURN_URL = "budibase:account:returnurl",

View file

@ -104,6 +104,7 @@ const environment = {
SMTP_PORT: parseInt(process.env.SMTP_PORT || ""), SMTP_PORT: parseInt(process.env.SMTP_PORT || ""),
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS, SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING, DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING,
BLACKLIST_IPS: process.env.BLACKLIST_IPS,
/** /**
* Enable to allow an admin user to login using a password. * Enable to allow an admin user to login using a password.
* This can be useful to prevent lockout when configuring SSO. * This can be useful to prevent lockout when configuring SSO.

View file

@ -26,6 +26,7 @@ export * as utils from "./utils"
export * as errors from "./errors" export * as errors from "./errors"
export * as timers from "./timers" export * as timers from "./timers"
export { default as env } from "./environment" export { default as env } from "./environment"
export * as blacklist from "./blacklist"
export { SearchParams } from "./db" export { SearchParams } from "./db"
// Add context to tenancy for backwards compatibility // Add context to tenancy for backwards compatibility
// only do this for external usages to prevent internal // only do this for external usages to prevent internal

View file

@ -1,4 +1,6 @@
import { import {
ConfigType,
GoogleConfig,
GoogleInnerConfig, GoogleInnerConfig,
JwtClaims, JwtClaims,
OAuth2, OAuth2,
@ -10,10 +12,10 @@ import {
User, User,
} from "@budibase/types" } from "@budibase/types"
import { generator } from "./generator" import { generator } from "./generator"
import { uuid, email } from "./common" import { email, uuid } from "./common"
import * as shared from "./shared" import * as shared from "./shared"
import _ from "lodash"
import { user } from "./shared" import { user } from "./shared"
import _ from "lodash"
export function OAuth(): OAuth2 { export function OAuth(): OAuth2 {
return { return {
@ -107,3 +109,11 @@ export function googleConfig(): GoogleInnerConfig {
clientSecret: generator.string(), clientSecret: generator.string(),
} }
} }
export function googleConfigDoc(): GoogleConfig {
return {
_id: "config_google",
type: ConfigType.GOOGLE,
config: googleConfig(),
}
}

View file

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

View file

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

View file

@ -163,7 +163,12 @@ export const getComponentSettings = componentType => {
def.settings def.settings
?.filter(setting => setting.section) ?.filter(setting => setting.section)
.forEach(section => { .forEach(section => {
settings = settings.concat(section.settings || []) settings = settings.concat(
(section.settings || []).map(setting => ({
...setting,
section: section.name,
}))
)
}) })
} }
componentSettingCache[componentType] = settings componentSettingCache[componentType] = settings

View file

@ -32,8 +32,8 @@
import { getSchemaForTable } from "builderStore/dataBinding" import { getSchemaForTable } from "builderStore/dataBinding"
import { Utils } from "@budibase/frontend-core" import { Utils } from "@budibase/frontend-core"
import { TriggerStepID, ActionStepID } from "constants/backend/automations" import { TriggerStepID, ActionStepID } from "constants/backend/automations"
import { cloneDeep } from "lodash/fp"
import { onMount } from "svelte" import { onMount } from "svelte"
import { cloneDeep } from "lodash/fp"
export let block export let block
export let testData export let testData
@ -214,8 +214,6 @@
function saveFilters(key) { function saveFilters(key) {
const filters = LuceneUtils.buildLuceneQuery(tempFilters) const filters = LuceneUtils.buildLuceneQuery(tempFilters)
const defKey = `${key}-def` const defKey = `${key}-def`
inputData[key] = filters
inputData[defKey] = tempFilters
onChange({ detail: filters }, key) onChange({ detail: filters }, key)
// need to store the builder definition in the automation // need to store the builder definition in the automation
onChange({ detail: tempFilters }, defKey) onChange({ detail: tempFilters }, defKey)

View file

@ -95,8 +95,11 @@
} }
const onChange = (e, field, type) => { const onChange = (e, field, type) => {
value[field] = coerce(e.detail, type) let newValue = {
dispatch("change", value) ...value,
[field]: coerce(e.detail, type),
}
dispatch("change", newValue)
} }
const onChangeSetting = (e, field) => { const onChangeSetting = (e, field) => {

View file

@ -12,7 +12,7 @@
// kill the reference so the input isn't saved // kill the reference so the input isn't saved
let datasource = cloneDeep(integration) let datasource = cloneDeep(integration)
$: isGoogleConfigured = !!$organisation.google $: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
onMount(async () => { onMount(async () => {
await organisation.init() await organisation.init()

View file

@ -8,6 +8,7 @@
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
export let label = "" export let label = ""
export let labelHidden = false
export let componentInstance = {} export let componentInstance = {}
export let control = null export let control = null
export let key = "" export let key = ""
@ -76,10 +77,10 @@
<div <div
class="property-control" class="property-control"
class:wide={!label} class:wide={!label || labelHidden}
class:highlighted={highlighted && nullishValue} class:highlighted={highlighted && nullishValue}
> >
{#if label} {#if label && !labelHidden}
<Label size="M">{label}</Label> <Label size="M">{label}</Label>
{/if} {/if}
<div id={`${key}-prop-control`} class="control"> <div id={`${key}-prop-control`} class="control">

View file

@ -10,24 +10,27 @@
$: multiTenancyEnabled = $admin.multiTenancy $: multiTenancyEnabled = $admin.multiTenancy
$: hasAdminUser = $admin?.checklist?.adminUser?.checked $: hasAdminUser = $admin?.checklist?.adminUser?.checked
$: baseUrl = $admin?.baseUrl
$: tenantSet = $auth.tenantSet $: tenantSet = $auth.tenantSet
$: cloud = $admin.cloud $: cloud = $admin?.cloud
$: user = $auth.user $: user = $auth.user
$: useAccountPortal = cloud && !$admin.disableAccountPortal $: useAccountPortal = cloud && !$admin.disableAccountPortal
const validateTenantId = async () => { const validateTenantId = async () => {
const host = window.location.host const host = window.location.host
if (host.includes("localhost:")) { if (host.includes("localhost:") || !baseUrl) {
// ignore local dev // ignore local dev
return return
} }
// e.g. ['tenant', 'budibase', 'app'] vs ['budibase', 'app'] const mainHost = new URL(baseUrl).host
let urlTenantId let urlTenantId
const hostParts = host.split(".") // remove the main host part
if (hostParts.length > 2) { const hostParts = host.split(mainHost).filter(part => part !== "")
urlTenantId = hostParts[0] // if there is a part left, it has to be the tenant ID subdomain
if (hostParts.length === 1) {
urlTenantId = hostParts[0].replace(/\./g, "")
} }
if (user && user.tenantId) { if (user && user.tenantId) {
@ -47,7 +50,9 @@
await auth.logout() await auth.logout()
await auth.setOrganisation(null) await auth.setOrganisation(null)
} catch (error) { } catch (error) {
console.error("Tenant mis-match, logout.") console.error(
`Tenant mis-match - "${urlTenantId}" and "${user.tenantId}" - logout`
)
} }
} }
} else { } else {
@ -74,7 +79,7 @@
} }
// Validate tenant if in a multi-tenant env // Validate tenant if in a multi-tenant env
if (useAccountPortal && multiTenancyEnabled) { if (multiTenancyEnabled) {
await validateTenantId() await validateTenantId()
} }
} catch (error) { } catch (error) {

View file

@ -133,6 +133,7 @@
type={setting.type} type={setting.type}
control={getComponentForSetting(setting)} control={getComponentForSetting(setting)}
label={setting.label} label={setting.label}
labelHidden={setting.labelHidden}
key={setting.key} key={setting.key}
value={componentInstance[setting.key]} value={componentInstance[setting.key]}
defaultValue={setting.defaultValue} defaultValue={setting.defaultValue}

View file

@ -62,7 +62,7 @@
type: "text", type: "text",
}) })
$: settingOptions = settings.map(setting => ({ $: settingOptions = settings.map(setting => ({
label: setting.label, label: makeLabel(setting),
value: setting.key, value: setting.key,
})) }))
$: conditions.forEach(link => { $: conditions.forEach(link => {
@ -71,6 +71,15 @@
} }
}) })
const makeLabel = setting => {
const { section, label } = setting
if (section) {
return label ? `${section} - ${label}` : section
} else {
return label
}
}
const getSettingDefinition = key => { const getSettingDefinition = key => {
return settings.find(setting => setting.key === key) return settings.find(setting => setting.key === key)
} }

View file

@ -22,6 +22,18 @@ export function createTablesStore() {
})) }))
} }
const fetchTable = async tableId => {
const table = await API.fetchTableDefinition(tableId)
store.update(state => {
const indexToUpdate = state.list.findIndex(t => t._id === table._id)
state.list[indexToUpdate] = table
return {
...state,
}
})
}
const select = tableId => { const select = tableId => {
store.update(state => ({ store.update(state => ({
...state, ...state,
@ -126,6 +138,7 @@ export function createTablesStore() {
return { return {
subscribe: derivedStore.subscribe, subscribe: derivedStore.subscribe,
fetch, fetch,
fetchTable,
init: fetch, init: fetch,
select, select,
save, save,

View file

@ -53,6 +53,7 @@ export function createAdminStore() {
store.disableAccountPortal = environment.disableAccountPortal store.disableAccountPortal = environment.disableAccountPortal
store.accountPortalUrl = environment.accountPortalUrl store.accountPortalUrl = environment.accountPortalUrl
store.isDev = environment.isDev store.isDev = environment.isDev
store.baseUrl = environment.baseUrl
return store return store
}) })
} }

View file

@ -19,6 +19,7 @@ const DEFAULT_CONFIG = {
company: "Budibase", company: "Budibase",
oidc: undefined, oidc: undefined,
google: undefined, google: undefined,
googleDatasourceConfigured: undefined,
oidcCallbackUrl: "", oidcCallbackUrl: "",
googleCallbackUrl: "", googleCallbackUrl: "",
isSSOEnforced: false, isSSOEnforced: false,
@ -39,6 +40,7 @@ export function createOrganisationStore() {
const storeConfig = _.cloneDeep(get(store)) const storeConfig = _.cloneDeep(get(store))
delete storeConfig.oidc delete storeConfig.oidc
delete storeConfig.google delete storeConfig.google
delete storeConfig.googleDatasourceConfigured
delete storeConfig.oidcCallbackUrl delete storeConfig.oidcCallbackUrl
delete storeConfig.googleCallbackUrl delete storeConfig.googleCallbackUrl
await API.saveConfig({ await API.saveConfig({

View file

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

View file

@ -4389,6 +4389,8 @@
"name": "On row click", "name": "On row click",
"settings": [ "settings": [
{ {
"label": "Behaviour",
"labelHidden": true,
"type": "radio", "type": "radio",
"key": "clickBehaviour", "key": "clickBehaviour",
"sendEvents": true, "sendEvents": true,
@ -4406,6 +4408,8 @@
] ]
}, },
{ {
"label": "Actions",
"labelHidden": true,
"type": "event", "type": "event",
"key": "onClick", "key": "onClick",
"nested": true, "nested": true,
@ -4442,7 +4446,7 @@
{ {
"type": "radio", "type": "radio",
"key": "titleButtonClickBehaviour", "key": "titleButtonClickBehaviour",
"label": "Click behaviour", "label": "Behaviour",
"dependsOn": "showTitleButton", "dependsOn": "showTitleButton",
"defaultValue": "actions", "defaultValue": "actions",
"info": "New row side panel is only compatible with internal or SQL tables", "info": "New row side panel is only compatible with internal or SQL tables",
@ -4460,6 +4464,8 @@
{ {
"label": "On click", "label": "On click",
"type": "event", "type": "event",
"label": "On click",
"labelHidden": true,
"key": "onClickTitleButton", "key": "onClickTitleButton",
"nested": true, "nested": true,
"dependsOn": { "dependsOn": {

View file

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

View file

@ -1,13 +1,13 @@
{ {
"name": "@budibase/frontend-core", "name": "@budibase/frontend-core",
"version": "2.4.27-alpha.12", "version": "2.4.42-alpha.5",
"description": "Budibase frontend core libraries used in builder and client", "description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase", "author": "Budibase",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"dependencies": { "dependencies": {
"@budibase/bbui": "2.4.27-alpha.12", "@budibase/bbui": "2.4.42-alpha.5",
"@budibase/shared-core": "2.4.27-alpha.12", "@budibase/shared-core": "2.4.42-alpha.5",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"socket.io-client": "^4.6.1", "socket.io-client": "^4.6.1",

View file

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

View file

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

View file

@ -144,10 +144,15 @@ export async function search(ctx: any) {
export async function validate(ctx: Ctx) { export async function validate(ctx: Ctx) {
const tableId = getTableId(ctx) const tableId = getTableId(ctx)
// external tables are hard to validate currently
if (isExternalTable(tableId)) {
ctx.body = { valid: true }
} else {
ctx.body = await utils.validate({ ctx.body = await utils.validate({
row: ctx.request.body, row: ctx.request.body,
tableId, tableId,
}) })
}
} }
export async function fetchEnrichedRow(ctx: any) { export async function fetchEnrichedRow(ctx: any) {

View file

@ -23,7 +23,7 @@
<!-- Opengraph Meta Tags --> <!-- Opengraph Meta Tags -->
<meta property="og:site_name" content="Budibase" /> <meta property="og:site_name" content="Budibase" />
<meta property="og:title" content="{title} - built with Budibase" /> <meta property="og:title" content={metaTitle} />
<meta property="og:description" content={metaDescription} /> <meta property="og:description" content={metaDescription} />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:image" content={metaImage} /> <meta property="og:image" content={metaImage} />
@ -32,8 +32,8 @@
<meta property="twitter:card" content="summary_large_image" /> <meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:site" content="@budibase" /> <meta property="twitter:site" content="@budibase" />
<meta property="twitter:image" content={metaImage} /> <meta property="twitter:image" content={metaImage} />
<meta property="twitter:image:alt" content="{title} - built with Budibase" /> <meta property="twitter:image:alt" content={metaTitle} />
<meta property="twitter:title" content="{title} - built with Budibase" /> <meta property="twitter:title" content={metaTitle} />
<meta property="twitter:description" content={metaDescription} /> <meta property="twitter:description" content={metaDescription} />
<title>{title}</title> <title>{title}</title>

View file

@ -107,7 +107,7 @@ export function substituteLoopStep(hbsString: string, substitute: string) {
let pointer = 0, let pointer = 0,
openPointer = 0, openPointer = 0,
closedPointer = 0 closedPointer = 0
while (pointer < hbsString.length) { while (pointer < hbsString?.length) {
openPointer = hbsString.indexOf(open, pointer) openPointer = hbsString.indexOf(open, pointer)
closedPointer = hbsString.indexOf(closed, pointer) + 2 closedPointer = hbsString.indexOf(closed, pointer) + 2
if (openPointer < 0 || closedPointer < 0) { if (openPointer < 0 || closedPointer < 0) {

View file

@ -156,7 +156,7 @@ class InternalBuilder {
const rawFnc = `${fnc}Raw` const rawFnc = `${fnc}Raw`
// @ts-ignore // @ts-ignore
query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [ query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [
`%${value}%`, `%${value.toLowerCase()}%`,
]) ])
} }
} }
@ -202,7 +202,7 @@ class InternalBuilder {
let statement = "" let statement = ""
for (let i in value) { for (let i in value) {
if (typeof value[i] === "string") { if (typeof value[i] === "string") {
value[i] = `%"${value[i]}"%` value[i] = `%"${value[i].toLowerCase()}"%`
} else { } else {
value[i] = `%${value[i]}%` value[i] = `%${value[i]}%`
} }
@ -238,7 +238,7 @@ class InternalBuilder {
const rawFnc = `${fnc}Raw` const rawFnc = `${fnc}Raw`
// @ts-ignore // @ts-ignore
query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [ query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [
`${value}%`, `${value.toLowerCase()}%`,
]) ])
} }
}) })

View file

@ -19,6 +19,7 @@ import { formatBytes } from "../utilities"
import { performance } from "perf_hooks" import { performance } from "perf_hooks"
import FormData from "form-data" import FormData from "form-data"
import { URLSearchParams } from "url" import { URLSearchParams } from "url"
import { blacklist } from "@budibase/backend-core"
const BodyTypes = { const BodyTypes = {
NONE: "none", NONE: "none",
@ -398,6 +399,9 @@ class RestIntegration implements IntegrationBase {
this.startTimeMs = performance.now() this.startTimeMs = performance.now()
const url = this.getUrl(path, queryString, pagination, paginationValues) const url = this.getUrl(path, queryString, pagination, paginationValues)
if (await blacklist.isBlacklisted(url)) {
throw new Error("Cannot connect to URL.")
}
const response = await fetch(url, input) const response = await fetch(url, input)
return await this.parseResponse(response, pagination) return await this.parseResponse(response, pagination)
} }

View file

@ -351,7 +351,7 @@ describe("SQL query builder", () => {
}) })
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`], bindings: [10, "%20%", "%25%", `%"john"%`, `%"mary"%`],
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER([${TABLE_NAME}].[age]) LIKE @p1 AND LOWER([${TABLE_NAME}].[age]) LIKE @p2) and (LOWER([${TABLE_NAME}].[name]) LIKE @p3 AND LOWER([${TABLE_NAME}].[name]) LIKE @p4)) as [${TABLE_NAME}]`, sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER([${TABLE_NAME}].[age]) LIKE @p1 AND LOWER([${TABLE_NAME}].[age]) LIKE @p2) and (LOWER([${TABLE_NAME}].[name]) LIKE @p3 AND LOWER([${TABLE_NAME}].[name]) LIKE @p4)) as [${TABLE_NAME}]`,
}) })
}) })
@ -402,7 +402,7 @@ describe("SQL query builder", () => {
}) })
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [10, "%20%", `%"John"%`], bindings: [10, "%20%", `%"john"%`],
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER([${TABLE_NAME}].[age]) LIKE @p1) and NOT (LOWER([${TABLE_NAME}].[name]) LIKE @p2)) as [${TABLE_NAME}]`, sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER([${TABLE_NAME}].[age]) LIKE @p1) and NOT (LOWER([${TABLE_NAME}].[name]) LIKE @p2)) as [${TABLE_NAME}]`,
}) })
}) })
@ -453,7 +453,7 @@ describe("SQL query builder", () => {
}) })
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`], bindings: [10, "%20%", "%25%", `%"john"%`, `%"mary"%`],
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER([${TABLE_NAME}].[age]) LIKE @p1 OR LOWER([${TABLE_NAME}].[age]) LIKE @p2) and (LOWER([${TABLE_NAME}].[name]) LIKE @p3 OR LOWER([${TABLE_NAME}].[name]) LIKE @p4)) as [${TABLE_NAME}]`, sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER([${TABLE_NAME}].[age]) LIKE @p1 OR LOWER([${TABLE_NAME}].[age]) LIKE @p2) and (LOWER([${TABLE_NAME}].[name]) LIKE @p3 OR LOWER([${TABLE_NAME}].[name]) LIKE @p4)) as [${TABLE_NAME}]`,
}) })
}) })
@ -531,7 +531,7 @@ describe("SQL query builder", () => {
}) })
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: ["John%", limit], bindings: ["john%", limit],
sql: `select * from (select * from \`${tableName}\` where LOWER(\`${tableName}\`.\`name\`) LIKE ? limit ?) as \`${tableName}\``, sql: `select * from (select * from \`${tableName}\` where LOWER(\`${tableName}\`.\`name\`) LIKE ? limit ?) as \`${tableName}\``,
}) })
}) })
@ -549,7 +549,7 @@ describe("SQL query builder", () => {
}) })
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [limit, "John%"], bindings: [limit, "john%"],
sql: `select * from (select top (@p0) * from [${tableName}] where LOWER([${tableName}].[name]) LIKE @p1) as [${tableName}]`, sql: `select * from (select top (@p0) * from [${tableName}] where LOWER([${tableName}].[name]) LIKE @p1) as [${tableName}]`,
}) })
}) })
@ -591,4 +591,49 @@ describe("SQL query builder", () => {
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"dob\" < $1 limit $2) as \"${TABLE_NAME}\"`, sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"dob\" < $1 limit $2) as \"${TABLE_NAME}\"`,
}) })
}) })
it("should lowercase the values for Oracle LIKE statements", () => {
let query = new Sql(SqlClient.ORACLE, limit)._query(
generateReadJson({
filters: {
string: {
name: "John",
},
},
})
)
expect(query).toEqual({
bindings: ["john%", limit],
sql: `select * from (select * from (select * from \"test\" where LOWER(\"test\".\"name\") LIKE :1) where rownum <= :2) \"test\"`,
})
query = new Sql(SqlClient.ORACLE, limit)._query(
generateReadJson({
filters: {
contains: {
age: [20, 25],
name: ["John", "Mary"],
},
},
})
)
expect(query).toEqual({
bindings: ["%20%", "%25%", `%"john"%`, `%"mary"%`, limit],
sql: `select * from (select * from (select * from \"test\" where (LOWER(\"test\".\"age\") LIKE :1 AND LOWER(\"test\".\"age\") LIKE :2) and (LOWER(\"test\".\"name\") LIKE :3 AND LOWER(\"test\".\"name\") LIKE :4)) where rownum <= :5) \"test\"`,
})
query = new Sql(SqlClient.ORACLE, limit)._query(
generateReadJson({
filters: {
fuzzy: {
name: "Jo",
},
},
})
)
expect(query).toEqual({
bindings: [`%jo%`, limit],
sql: `select * from (select * from (select * from \"test\" where LOWER(\"test\".\"name\") LIKE :1) where rownum <= :2) \"test\"`,
})
})
}) })

View file

@ -2,7 +2,6 @@ import {
utils, utils,
constants, constants,
roles, roles,
db as dbCore,
tenancy, tenancy,
context, context,
} from "@budibase/backend-core" } from "@budibase/backend-core"
@ -15,29 +14,10 @@ import { UserCtx } from "@budibase/types"
export default async (ctx: UserCtx, next: any) => { export default async (ctx: UserCtx, next: any) => {
// try to get the appID from the request // try to get the appID from the request
let requestAppId = await utils.getAppIdFromCtx(ctx) let requestAppId = await utils.getAppIdFromCtx(ctx)
// get app cookie if it exists if (!requestAppId) {
let appCookie: { appId?: string } | undefined
try {
appCookie = utils.getCookie(ctx, constants.Cookie.CurrentApp)
} catch (err) {
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
}
if (!appCookie && !requestAppId) {
return next() return next()
} }
// check the app exists referenced in cookie
if (appCookie) {
const appId = appCookie.appId
const exists = await dbCore.dbExists(appId)
if (!exists) {
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
return next()
}
// if the request app ID wasn't set, update it with the cookie
requestAppId = requestAppId || appId
}
// deny access to application preview // deny access to application preview
if (!env.isTest()) { if (!env.isTest()) {
if ( if (
@ -45,7 +25,6 @@ export default async (ctx: UserCtx, next: any) => {
!isWebhookEndpoint(ctx) && !isWebhookEndpoint(ctx) &&
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global) (!ctx.user || !ctx.user.builder || !ctx.user.builder.global)
) { ) {
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
return ctx.redirect("/") return ctx.redirect("/")
} }
} }
@ -127,14 +106,6 @@ export default async (ctx: UserCtx, next: any) => {
role: await roles.getRole(roleId), role: await roles.getRole(roleId),
} }
} }
if (
(requestAppId !== appId ||
appCookie == null ||
appCookie.appId !== requestAppId) &&
!skipCookie
) {
utils.setCookie(ctx, { appId }, constants.Cookie.CurrentApp)
}
return next() return next()
}) })

View file

@ -158,27 +158,22 @@ describe("Current app middleware", () => {
}) })
describe("check functionality when logged in", () => { describe("check functionality when logged in", () => {
async function checkExpected(setCookie) { async function checkExpected() {
config.setUser() config.setUser()
await config.executeMiddleware() await config.executeMiddleware()
let { utils } = require("@budibase/backend-core")
if (setCookie) {
expect(utils.setCookie).toHaveBeenCalled()
} else {
expect(utils.setCookie).not.toHaveBeenCalled()
}
expect(config.ctx.roleId).toEqual("PUBLIC") expect(config.ctx.roleId).toEqual("PUBLIC")
expect(config.ctx.user.role._id).toEqual("PUBLIC") expect(config.ctx.user.role._id).toEqual("PUBLIC")
expect(config.ctx.appId).toEqual("app_test") expect(config.ctx.appId).toEqual("app_test")
expect(config.next).toHaveBeenCalled() expect(config.next).toHaveBeenCalled()
} }
it("should be able to setup an app token when cookie not setup", async () => { it("should be able to setup an app token on a first call", async () => {
mockAuthWithCookie() mockAuthWithCookie()
await checkExpected(true) await checkExpected()
}) })
it("should perform correct when no cookie exists", async () => { it("should perform correct on a first call", async () => {
mockReset() mockReset()
jest.mock("@budibase/backend-core", () => { jest.mock("@budibase/backend-core", () => {
const core = jest.requireActual("@budibase/backend-core") const core = jest.requireActual("@budibase/backend-core")
@ -206,38 +201,7 @@ describe("Current app middleware", () => {
}, },
} }
}) })
await checkExpected(true) await checkExpected()
})
it("lastly check what occurs when cookie doesn't need updated", async () => {
mockReset()
jest.mock("@budibase/backend-core", () => {
const core = jest.requireActual("@budibase/backend-core")
return {
...core,
db: {
...core.db,
dbExists: () => true,
},
utils: {
getAppIdFromCtx: () => {
return "app_test"
},
setCookie: jest.fn(),
getCookie: () => ({ appId: "app_test", roleId: "PUBLIC" }),
},
cache: {
user: {
getUser: async id => {
return {
_id: "us_uuid1",
}
},
},
},
}
})
await checkExpected(false)
}) })
}) })
}) })

View file

@ -330,21 +330,13 @@ class TestConfiguration {
sessionId: "sessionid", sessionId: "sessionid",
tenantId: this.getTenantId(), tenantId: this.getTenantId(),
} }
const app = {
roleId: roleId,
appId,
}
const authToken = auth.jwt.sign(authObj, coreEnv.JWT_SECRET) const authToken = auth.jwt.sign(authObj, coreEnv.JWT_SECRET)
const appToken = auth.jwt.sign(app, coreEnv.JWT_SECRET)
// returning necessary request headers // returning necessary request headers
await cache.user.invalidateUser(userId) await cache.user.invalidateUser(userId)
return { return {
Accept: "application/json", Accept: "application/json",
Cookie: [ Cookie: [`${constants.Cookie.Auth}=${authToken}`],
`${constants.Cookie.Auth}=${authToken}`,
`${constants.Cookie.CurrentApp}=${appToken}`,
],
[constants.Header.APP_ID]: appId, [constants.Header.APP_ID]: appId,
} }
}) })
@ -359,18 +351,11 @@ class TestConfiguration {
sessionId: "sessionid", sessionId: "sessionid",
tenantId, tenantId,
} }
const app = {
roleId: roles.BUILTIN_ROLE_IDS.ADMIN,
appId: this.appId,
}
const authToken = auth.jwt.sign(authObj, coreEnv.JWT_SECRET) const authToken = auth.jwt.sign(authObj, coreEnv.JWT_SECRET)
const appToken = auth.jwt.sign(app, coreEnv.JWT_SECRET)
const headers: any = { const headers: any = {
Accept: "application/json", Accept: "application/json",
Cookie: [ Cookie: [`${constants.Cookie.Auth}=${authToken}`],
`${constants.Cookie.Auth}=${authToken}`,
`${constants.Cookie.CurrentApp}=${appToken}`,
],
[constants.Header.CSRF_TOKEN]: this.defaultUserValues.csrfToken, [constants.Header.CSRF_TOKEN]: this.defaultUserValues.csrfToken,
Host: this.tenantHost(), Host: this.tenantHost(),
...extras, ...extras,

View file

@ -1290,14 +1290,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.27-alpha.12": "@budibase/backend-core@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.12.tgz#655367eaa16a8bf1a28ff38eb0ab2127decb5b23" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.42-alpha.5.tgz#3e4b44c6e1b7f9c0652527a48dfa46dbe022e93b"
integrity sha512-qCszwPDuYvMYZLl54T82ZrpM5xHD6nTEzPAkPQFrZIDtkW1dfKd2z+E2OirIOYb1CRN4GwrnIDjR0+u231Qo5w== integrity sha512-vclysH06NASv9XZ55W9yonPIodVTCWklo6alfKPQTbvjINGBopfTglV9new+OVJoqlaYPyt4AyBVp0si29vuKg==
dependencies: dependencies:
"@budibase/nano" "10.1.2" "@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10" "@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.27-alpha.12" "@budibase/types" "2.4.42-alpha.5"
"@shopify/jest-koa-mocks" "5.0.1" "@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0" aws-cloudfront-sign "2.2.0"
@ -1429,14 +1429,14 @@
pouchdb-promise "^6.0.4" pouchdb-promise "^6.0.4"
through2 "^2.0.0" through2 "^2.0.0"
"@budibase/pro@2.4.27-alpha.12": "@budibase/pro@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.12.tgz#c3f74e4ef04ea1355bdc1333dd033f4a47087ac2" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.42-alpha.5.tgz#99774e2e06fc22892c545b7208d78144395859db"
integrity sha512-Hl/zalqmtlINgylFqQz3zWG/4dTXm/Skck2Q/j69gyqy0DotWXfRko03CbDQCyHGWhM/oXXiYJK54HIkn+kOTw== integrity sha512-Axxx4zqsBsu2fl5UKetNXCJWoMi2pcA/kVY88Z9BYNPmGp7k3s2pKU/kShy751I2fDF0TGgxSCGzpVzWqM8ZEg==
dependencies: dependencies:
"@budibase/backend-core" "2.4.27-alpha.12" "@budibase/backend-core" "2.4.42-alpha.5"
"@budibase/string-templates" "2.3.20" "@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.27-alpha.12" "@budibase/types" "2.4.42-alpha.5"
"@koa/router" "8.0.8" "@koa/router" "8.0.8"
bull "4.10.1" bull "4.10.1"
joi "17.6.0" joi "17.6.0"
@ -1475,10 +1475,10 @@
lodash "^4.17.20" lodash "^4.17.20"
vm2 "^3.9.4" vm2 "^3.9.4"
"@budibase/types@2.4.27-alpha.12": "@budibase/types@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.12.tgz#4c0dd66434f52c41080c17b810262ff8f195cb6c" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.42-alpha.5.tgz#21408ab88b74833f176003f9e54dc109252d8080"
integrity sha512-mpzlQM49WWQyWnysFcMkJDD3jY6Wf5HG7R8/eb5PRbSWx92+17g0iCbhuaswfCJdz0GIi73hebmvaFeuQ/glMg== integrity sha512-3uZmKryzMcAxIrR0hnBwoNfuqR8yvCWjK880h4Mdi2ik/uYfndUAhdVi/Bh/oU3ZGu9KiJzqh/IE29IuRboiNg==
"@bull-board/api@3.7.0": "@bull-board/api@3.7.0":
version "3.7.0" version "3.7.0"

View file

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

View file

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

View file

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

View file

@ -5,6 +5,7 @@ import { SettingsConfig, SettingsInnerConfig } from "../../../documents"
*/ */
export interface PublicSettingsInnerConfig extends SettingsInnerConfig { export interface PublicSettingsInnerConfig extends SettingsInnerConfig {
google: boolean google: boolean
googleDatasourceConfigured: boolean
oidc: boolean oidc: boolean
oidcCallbackUrl: string oidcCallbackUrl: string
googleCallbackUrl: string googleCallbackUrl: string

View file

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

View file

@ -50,11 +50,6 @@ async function passportCallback(
setCookie(ctx, token, Cookie.Auth, { sign: false }) setCookie(ctx, token, Cookie.Auth, { sign: false })
// set the token in a header as well for APIs // set the token in a header as well for APIs
ctx.set(Header.TOKEN, token) ctx.set(Header.TOKEN, token)
// get rid of any app cookies on login
// have to check test because this breaks cypress
if (!env.isTest()) {
clearCookie(ctx, Cookie.CurrentApp)
}
} }
export const login = async (ctx: Ctx<LoginRequest>, next: any) => { export const login = async (ctx: Ctx<LoginRequest>, next: any) => {

View file

@ -332,6 +332,8 @@ export async function publicSettings(
// google // google
const googleConfig = await configs.getGoogleConfig() const googleConfig = await configs.getGoogleConfig()
const googleDatasourceConfigured =
!!(await configs.getGoogleDatasourceConfig())
const preActivated = googleConfig && googleConfig.activated == null const preActivated = googleConfig && googleConfig.activated == null
const google = preActivated || !!googleConfig?.activated const google = preActivated || !!googleConfig?.activated
const _googleCallbackUrl = await googleCallbackUrl(googleConfig) const _googleCallbackUrl = await googleCallbackUrl(googleConfig)
@ -352,6 +354,7 @@ export async function publicSettings(
...config, ...config,
...branding, ...branding,
google, google,
googleDatasourceConfigured,
oidc, oidc,
isSSOEnforced, isSSOEnforced,
oidcCallbackUrl: _oidcCallbackUrl, oidcCallbackUrl: _oidcCallbackUrl,

View file

@ -2,7 +2,6 @@ import * as userSdk from "../../../sdk/users"
import { import {
featureFlags, featureFlags,
tenancy, tenancy,
constants,
db as dbCore, db as dbCore,
utils, utils,
encryption, encryption,
@ -11,7 +10,7 @@ import {
import env from "../../../environment" import env from "../../../environment"
import { groups } from "@budibase/pro" import { groups } from "@budibase/pro"
import { UpdateSelfRequest, UpdateSelfResponse, UserCtx } from "@budibase/types" import { UpdateSelfRequest, UpdateSelfResponse, UserCtx } from "@budibase/types"
const { getCookie, clearCookie, newid } = utils const { newid } = utils
function newTestApiKey() { function newTestApiKey() {
return env.ENCRYPTED_TEST_PUBLIC_API_KEY return env.ENCRYPTED_TEST_PUBLIC_API_KEY
@ -71,16 +70,6 @@ export async function fetchAPIKey(ctx: any) {
ctx.body = cleanupDevInfo(devInfo) ctx.body = cleanupDevInfo(devInfo)
} }
const checkCurrentApp = (ctx: any) => {
const appCookie = getCookie(ctx, constants.Cookie.CurrentApp)
if (appCookie && !tenancy.isUserInAppTenant(appCookie.appId)) {
// there is a currentapp cookie from another tenant
// remove the cookie as this is incompatible with the builder
// due to builder and admin permissions being removed
clearCookie(ctx, constants.Cookie.CurrentApp)
}
}
/** /**
* Add the attributes that are session based to the current user. * Add the attributes that are session based to the current user.
*/ */
@ -101,8 +90,6 @@ export async function getSelf(ctx: any) {
id: userId, id: userId,
} }
checkCurrentApp(ctx)
// get the main body of the user // get the main body of the user
const user = await userSdk.getUser(userId) const user = await userSdk.getUser(userId)
ctx.body = await groups.enrichUserRolesFromGroups(user) ctx.body = await groups.enrichUserRolesFromGroups(user)

View file

@ -7,6 +7,7 @@ export const fetch = async (ctx: BBContext) => {
cloud: !env.SELF_HOSTED, cloud: !env.SELF_HOSTED,
accountPortalUrl: env.ACCOUNT_PORTAL_URL, accountPortalUrl: env.ACCOUNT_PORTAL_URL,
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL, disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
baseUrl: env.PLATFORM_URL,
// in test need to pretend its in production for the UI (Cypress) // in test need to pretend its in production for the UI (Cypress)
isDev: env.isDev() && !env.isTest(), isDev: env.isDev() && !env.isTest(),
} }

View file

@ -5,7 +5,7 @@ export async function destroy(ctx: UserCtx) {
const user = ctx.user! const user = ctx.user!
const tenantId = ctx.params.tenantId const tenantId = ctx.params.tenantId
if (tenantId !== user.tenantId) { if (!ctx.internal && tenantId !== user.tenantId) {
ctx.throw(403, "Tenant ID does not match current user") ctx.throw(403, "Tenant ID does not match current user")
} }
@ -17,3 +17,7 @@ export async function destroy(ctx: UserCtx) {
throw err throw err
} }
} }
export async function info(ctx: UserCtx) {
ctx.body = await tenantSdk.tenantInfo(ctx.params.tenantId)
}

View file

@ -290,6 +290,7 @@ describe("configs", () => {
logoUrl: "", logoUrl: "",
analyticsEnabled: false, analyticsEnabled: false,
google: false, google: false,
googleDatasourceConfigured: false,
googleCallbackUrl: `http://localhost:10000/api/global/auth/${config.tenantId}/google/callback`, googleCallbackUrl: `http://localhost:10000/api/global/auth/${config.tenantId}/google/callback`,
isSSOEnforced: false, isSSOEnforced: false,
oidc: false, oidc: false,

View file

@ -23,6 +23,7 @@ describe("/api/system/environment", () => {
disableAccountPortal: 0, disableAccountPortal: 0,
isDev: false, isDev: false,
multiTenancy: true, multiTenancy: true,
baseUrl: "http://localhost:10000",
}) })
}) })
}) })

View file

@ -74,3 +74,10 @@ async function removeTenantUsers(tenantId: string) {
throw err throw err
} }
} }
export async function tenantInfo(tenantId: string) {
const globalDbName = tenancy.getGlobalDBName(tenantId)
return {
exists: await dbCore.dbExists(globalDbName),
}
}

View file

@ -2,8 +2,10 @@ import TestConfiguration from "../TestConfiguration"
import { TestAPI, TestAPIOpts } from "./base" import { TestAPI, TestAPIOpts } from "./base"
export class TenantAPI extends TestAPI { export class TenantAPI extends TestAPI {
config: TestConfiguration
constructor(config: TestConfiguration) { constructor(config: TestConfiguration) {
super(config) super(config)
this.config = config
} }
delete = (tenantId: string, opts?: TestAPIOpts) => { delete = (tenantId: string, opts?: TestAPIOpts) => {

View file

@ -475,14 +475,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.27-alpha.12": "@budibase/backend-core@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.27-alpha.12.tgz#655367eaa16a8bf1a28ff38eb0ab2127decb5b23" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.42-alpha.5.tgz#3e4b44c6e1b7f9c0652527a48dfa46dbe022e93b"
integrity sha512-qCszwPDuYvMYZLl54T82ZrpM5xHD6nTEzPAkPQFrZIDtkW1dfKd2z+E2OirIOYb1CRN4GwrnIDjR0+u231Qo5w== integrity sha512-vclysH06NASv9XZ55W9yonPIodVTCWklo6alfKPQTbvjINGBopfTglV9new+OVJoqlaYPyt4AyBVp0si29vuKg==
dependencies: dependencies:
"@budibase/nano" "10.1.2" "@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10" "@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.27-alpha.12" "@budibase/types" "2.4.42-alpha.5"
"@shopify/jest-koa-mocks" "5.0.1" "@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0" aws-cloudfront-sign "2.2.0"
@ -564,14 +564,14 @@
pouchdb-promise "^6.0.4" pouchdb-promise "^6.0.4"
through2 "^2.0.0" through2 "^2.0.0"
"@budibase/pro@2.4.27-alpha.12": "@budibase/pro@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.27-alpha.12.tgz#c3f74e4ef04ea1355bdc1333dd033f4a47087ac2" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.42-alpha.5.tgz#99774e2e06fc22892c545b7208d78144395859db"
integrity sha512-Hl/zalqmtlINgylFqQz3zWG/4dTXm/Skck2Q/j69gyqy0DotWXfRko03CbDQCyHGWhM/oXXiYJK54HIkn+kOTw== integrity sha512-Axxx4zqsBsu2fl5UKetNXCJWoMi2pcA/kVY88Z9BYNPmGp7k3s2pKU/kShy751I2fDF0TGgxSCGzpVzWqM8ZEg==
dependencies: dependencies:
"@budibase/backend-core" "2.4.27-alpha.12" "@budibase/backend-core" "2.4.42-alpha.5"
"@budibase/string-templates" "2.3.20" "@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.27-alpha.12" "@budibase/types" "2.4.42-alpha.5"
"@koa/router" "8.0.8" "@koa/router" "8.0.8"
bull "4.10.1" bull "4.10.1"
joi "17.6.0" joi "17.6.0"
@ -592,10 +592,10 @@
lodash "^4.17.20" lodash "^4.17.20"
vm2 "^3.9.4" vm2 "^3.9.4"
"@budibase/types@2.4.27-alpha.12": "@budibase/types@2.4.42-alpha.5":
version "2.4.27-alpha.12" version "2.4.42-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.27-alpha.12.tgz#4c0dd66434f52c41080c17b810262ff8f195cb6c" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.42-alpha.5.tgz#21408ab88b74833f176003f9e54dc109252d8080"
integrity sha512-mpzlQM49WWQyWnysFcMkJDD3jY6Wf5HG7R8/eb5PRbSWx92+17g0iCbhuaswfCJdz0GIi73hebmvaFeuQ/glMg== integrity sha512-3uZmKryzMcAxIrR0hnBwoNfuqR8yvCWjK880h4Mdi2ik/uYfndUAhdVi/Bh/oU3ZGu9KiJzqh/IE29IuRboiNg==
"@cspotcode/source-map-support@^0.8.0": "@cspotcode/source-map-support@^0.8.0":
version "0.8.1" version "0.8.1"

View file

@ -21,7 +21,7 @@
"api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test", "api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test",
"api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test", "api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test",
"api:test:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", "api:test:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"",
"api:test:nightly": "env-cmd jest --runInBand --outputFile=testResults.json" "api:test:nightly": "env-cmd jest --runInBand --json --outputFile=testResults.json"
}, },
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",

View file

@ -10,7 +10,7 @@ const GITHUB_ACTIONS_RUN_URL = process.env.GITHUB_ACTIONS_RUN_URL
async function generateReport() { async function generateReport() {
// read the report file // read the report file
const REPORT_PATH = path.resolve(__dirname, "..", "testReport.json") const REPORT_PATH = path.resolve(__dirname, "..", "testResults.json")
const report = fs.readFileSync(REPORT_PATH, "utf-8") const report = fs.readFileSync(REPORT_PATH, "utf-8")
return JSON.parse(report) return JSON.parse(report)
} }