Merge remote-tracking branch 'origin/master' into fix/bindings-fixes
This commit is contained in:
commit
fd558a46bb
18 changed files with 228 additions and 403 deletions
2
.github/workflows/release-develop.yml
vendored
2
.github/workflows/release-develop.yml
vendored
|
@ -60,7 +60,7 @@ jobs:
|
|||
node scripts/syncLocalDependencies.js $version
|
||||
echo "Syncing yarn workspace"
|
||||
yarn
|
||||
- run: yarn build --configuration=production
|
||||
- run: yarn build
|
||||
- run: yarn build:sdk
|
||||
|
||||
- name: Publish budibase packages to NPM
|
||||
|
|
2
.github/workflows/release-master.yml
vendored
2
.github/workflows/release-master.yml
vendored
|
@ -54,7 +54,7 @@ jobs:
|
|||
echo "Syncing yarn workspace"
|
||||
yarn
|
||||
- run: yarn lint
|
||||
- run: yarn build --configuration=production
|
||||
- run: yarn build
|
||||
- run: yarn build:sdk
|
||||
|
||||
- name: Publish budibase packages to NPM
|
||||
|
|
|
@ -11,12 +11,14 @@ RUN chmod +x /cleanup.sh
|
|||
# build server
|
||||
WORKDIR /app
|
||||
ADD packages/server .
|
||||
RUN yarn install --frozen-lockfile --production=true && /cleanup.sh
|
||||
COPY yarn.lock .
|
||||
RUN yarn install --production=true && /cleanup.sh
|
||||
|
||||
# build worker
|
||||
WORKDIR /worker
|
||||
ADD packages/worker .
|
||||
RUN yarn install --frozen-lockfile --production=true && /cleanup.sh
|
||||
COPY yarn.lock .
|
||||
RUN yarn install --production=true && /cleanup.sh
|
||||
|
||||
FROM budibase/couchdb
|
||||
ARG TARGETARCH
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.7.1",
|
||||
"version": "2.7.4",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/backend-core",
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream --parallel dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker",
|
||||
"dev:server": "yarn run kill-server && lerna run --stream --parallel dev:builder --scope @budibase/worker --scope @budibase/server",
|
||||
"dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream --parallel dev:built",
|
||||
"dev:docker": "yarn build && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",
|
||||
"dev:docker": "yarn build:docker:pre && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",
|
||||
"test": "lerna run --stream test --stream",
|
||||
"lint:eslint": "eslint packages && eslint qa-core",
|
||||
"lint:prettier": "prettier --check \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --check \"qa-core/**/*.{js,ts,svelte}\"",
|
||||
|
@ -62,7 +62,7 @@
|
|||
"lint:fix": "yarn run lint:fix:prettier && yarn run lint:fix:eslint",
|
||||
"build:specs": "lerna run --stream specs",
|
||||
"build:docker": "lerna run --stream build:docker && yarn build:docker:proxy && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION && cd -",
|
||||
"build:docker:pre": "lerna run --stream build && lerna run --stream predocker",
|
||||
"build:docker:pre": "yarn build && lerna run --stream predocker",
|
||||
"build:docker:proxy": "docker build hosting/proxy -t proxy-service",
|
||||
"build:docker:selfhost": "lerna run --stream build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh latest && cd -",
|
||||
"build:docker:develop": "node scripts/pinVersions && lerna run --stream build:docker && yarn build:docker:proxy && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh develop && cd -",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as google from "../sso/google"
|
||||
import { Cookie } from "../../../constants"
|
||||
import { clearCookie, getCookie } from "../../../utils"
|
||||
import { doWithDB } from "../../../db"
|
||||
import * as configs from "../../../configs"
|
||||
import { BBContext, SSOProfile } from "@budibase/types"
|
||||
import { BBContext, Database, SSOProfile } from "@budibase/types"
|
||||
import { ssoSaveUserNoOp } from "../sso/sso"
|
||||
import { cache, utils } from "../../../"
|
||||
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy
|
||||
|
||||
type Passport = {
|
||||
|
@ -36,8 +36,8 @@ export async function preAuth(
|
|||
ssoSaveUserNoOp
|
||||
)
|
||||
|
||||
if (!ctx.query.appId) {
|
||||
ctx.throw(400, "appId query param not present.")
|
||||
if (!ctx.query.appId || !ctx.query.datasourceId) {
|
||||
ctx.throw(400, "appId and datasourceId query params not present.")
|
||||
}
|
||||
|
||||
return passport.authenticate(strategy, {
|
||||
|
@ -69,7 +69,7 @@ export async function postAuth(
|
|||
(
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
_profile: SSOProfile,
|
||||
profile: SSOProfile,
|
||||
done: Function
|
||||
) => {
|
||||
clearCookie(ctx, Cookie.DatasourceAuth)
|
||||
|
@ -79,16 +79,23 @@ export async function postAuth(
|
|||
{ successRedirect: "/", failureRedirect: "/error" },
|
||||
async (err: any, tokens: string[]) => {
|
||||
const baseUrl = `/builder/app/${authStateCookie.appId}/data`
|
||||
|
||||
const id = utils.newid()
|
||||
await cache.store(
|
||||
`datasource:creation:${authStateCookie.appId}:google:${id}`,
|
||||
{
|
||||
tokens,
|
||||
// update the DB for the datasource with all the user info
|
||||
await doWithDB(authStateCookie.appId, async (db: Database) => {
|
||||
let datasource
|
||||
try {
|
||||
datasource = await db.get(authStateCookie.datasourceId)
|
||||
} catch (err: any) {
|
||||
if (err.status === 404) {
|
||||
ctx.redirect(baseUrl)
|
||||
}
|
||||
)
|
||||
|
||||
ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`)
|
||||
}
|
||||
if (!datasource.config) {
|
||||
datasource.config = {}
|
||||
}
|
||||
datasource.config.auth = { type: "google", ...tokens }
|
||||
await db.put(datasource)
|
||||
ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`)
|
||||
})
|
||||
}
|
||||
)(ctx, next)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
import { store } from "builderStore"
|
||||
import { auth } from "stores/portal"
|
||||
|
||||
export let preAuthStep
|
||||
export let datasource
|
||||
export let disabled
|
||||
export let samePage
|
||||
|
||||
|
@ -13,8 +15,18 @@
|
|||
class:disabled
|
||||
{disabled}
|
||||
on:click={async () => {
|
||||
let ds = datasource
|
||||
let appId = $store.appId
|
||||
const url = `/api/global/auth/${tenantId}/datasource/google?appId=${appId}`
|
||||
if (!ds) {
|
||||
const resp = await preAuthStep()
|
||||
if (resp.datasource && resp.appId) {
|
||||
ds = resp.datasource
|
||||
appId = resp.appId
|
||||
} else {
|
||||
ds = resp
|
||||
}
|
||||
}
|
||||
const url = `/api/global/auth/${tenantId}/datasource/google?datasourceId=${ds._id}&appId=${appId}`
|
||||
if (samePage) {
|
||||
window.location = url
|
||||
} else {
|
||||
|
|
|
@ -1,92 +1,38 @@
|
|||
<script>
|
||||
import {
|
||||
ModalContent,
|
||||
Body,
|
||||
Layout,
|
||||
Link,
|
||||
notifications,
|
||||
} from "@budibase/bbui"
|
||||
import { IntegrationNames, IntegrationTypes } from "constants/backend"
|
||||
import { ModalContent, Body, Layout, Link } from "@budibase/bbui"
|
||||
import { IntegrationNames } from "constants/backend"
|
||||
import cloneDeep from "lodash/cloneDeepWith"
|
||||
import GoogleButton from "../_components/GoogleButton.svelte"
|
||||
import { saveDatasource as save } from "builderStore/datasource"
|
||||
import { organisation } from "stores/portal"
|
||||
import { onMount } from "svelte"
|
||||
import { validateDatasourceConfig } from "builderStore/datasource"
|
||||
import cloneDeep from "lodash/cloneDeepWith"
|
||||
import IntegrationConfigForm from "../TableIntegrationMenu/IntegrationConfigForm.svelte"
|
||||
import { goto } from "@roxi/routify"
|
||||
|
||||
import { saveDatasource } from "builderStore/datasource"
|
||||
import { DatasourceFeature } from "@budibase/types"
|
||||
|
||||
export let integration
|
||||
export let continueSetupId = false
|
||||
|
||||
// kill the reference so the input isn't saved
|
||||
let datasource = cloneDeep(integration)
|
||||
datasource.config.continueSetupId = continueSetupId
|
||||
|
||||
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
|
||||
|
||||
onMount(async () => {
|
||||
await organisation.init()
|
||||
})
|
||||
const integrationName = IntegrationNames[IntegrationTypes.GOOGLE_SHEETS]
|
||||
|
||||
export const GoogleDatasouceConfigStep = {
|
||||
AUTH: "Auth",
|
||||
SET_URL: "Set_url",
|
||||
}
|
||||
|
||||
let step = continueSetupId
|
||||
? GoogleDatasouceConfigStep.SET_URL
|
||||
: GoogleDatasouceConfigStep.AUTH
|
||||
|
||||
let isValid = false
|
||||
|
||||
const modalConfig = {
|
||||
[GoogleDatasouceConfigStep.AUTH]: {},
|
||||
[GoogleDatasouceConfigStep.SET_URL]: {
|
||||
confirmButtonText: "Connect",
|
||||
onConfirm: async () => {
|
||||
if (integration.features[DatasourceFeature.CONNECTION_CHECKING]) {
|
||||
const resp = await validateDatasourceConfig(datasource)
|
||||
if (!resp.connected) {
|
||||
notifications.error(`Unable to connect - ${resp.error}`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await saveDatasource(datasource)
|
||||
$goto(`./datasource/${resp._id}`)
|
||||
notifications.success(`Datasource created successfully.`)
|
||||
} catch (err) {
|
||||
notifications.error(err?.message ?? "Error saving datasource")
|
||||
// prevent the modal from closing
|
||||
return false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<ModalContent
|
||||
title={`Connect to ${integrationName}`}
|
||||
cancelText="Cancel"
|
||||
title={`Connect to ${IntegrationNames[datasource.type]}`}
|
||||
cancelText="Back"
|
||||
size="L"
|
||||
confirmText={modalConfig[step].confirmButtonText}
|
||||
showConfirmButton={!!modalConfig[step].onConfirm}
|
||||
onConfirm={modalConfig[step].onConfirm}
|
||||
disabled={!isValid}
|
||||
>
|
||||
{#if step === GoogleDatasouceConfigStep.AUTH}
|
||||
<!-- check true and false directly, don't render until flag is set -->
|
||||
{#if isGoogleConfigured === true}
|
||||
<Layout noPadding>
|
||||
<Body size="S"
|
||||
>Authenticate with your google account to use the {integrationName} integration.</Body
|
||||
>Authenticate with your google account to use the {IntegrationNames[
|
||||
datasource.type
|
||||
]} integration.</Body
|
||||
>
|
||||
</Layout>
|
||||
<GoogleButton samePage />
|
||||
<GoogleButton preAuthStep={() => save(datasource, true)} />
|
||||
{:else if isGoogleConfigured === false}
|
||||
<Body size="S"
|
||||
>Google authentication is not enabled, please complete Google SSO
|
||||
|
@ -94,17 +40,4 @@
|
|||
>
|
||||
<Link href="/builder/portal/settings/auth">Configure Google SSO</Link>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if step === GoogleDatasouceConfigStep.SET_URL}
|
||||
<Layout noPadding no>
|
||||
<Body size="S">Add the URL of the sheet you want to connect.</Body>
|
||||
|
||||
<IntegrationConfigForm
|
||||
schema={datasource.schema}
|
||||
bind:datasource
|
||||
creating={true}
|
||||
on:valid={e => (isValid = e.detail)}
|
||||
/>
|
||||
</Layout>
|
||||
{/if}
|
||||
</ModalContent>
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
import IntegrationIcon from "components/backend/DatasourceNavigator/IntegrationIcon.svelte"
|
||||
import ICONS from "components/backend/DatasourceNavigator/icons/index.js"
|
||||
import FontAwesomeIcon from "components/common/FontAwesomeIcon.svelte"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
let internalTableModal
|
||||
let externalDatasourceModal
|
||||
|
@ -130,19 +129,9 @@
|
|||
return integrationsArray
|
||||
}
|
||||
|
||||
let continueGoogleSetup
|
||||
onMount(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
continueGoogleSetup = urlParams.get("continue_google_setup")
|
||||
})
|
||||
|
||||
const fetchIntegrations = async () => {
|
||||
const unsortedIntegrations = await API.getIntegrations()
|
||||
integrations = sortIntegrations(unsortedIntegrations)
|
||||
|
||||
if (continueGoogleSetup) {
|
||||
handleIntegrationSelect(IntegrationTypes.GOOGLE_SHEETS)
|
||||
}
|
||||
}
|
||||
|
||||
$: fetchIntegrations()
|
||||
|
@ -152,17 +141,9 @@
|
|||
<CreateTableModal {promptUpload} afterSave={handleInternalTableSave} />
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
bind:this={externalDatasourceModal}
|
||||
on:hide={() => {
|
||||
continueGoogleSetup = null
|
||||
}}
|
||||
>
|
||||
<Modal bind:this={externalDatasourceModal}>
|
||||
{#if integration?.auth?.type === "google"}
|
||||
<GoogleDatasourceConfigModal
|
||||
continueSetupId={continueGoogleSetup}
|
||||
{integration}
|
||||
/>
|
||||
<GoogleDatasourceConfigModal {integration} />
|
||||
{:else}
|
||||
<DatasourceConfigModal {integration} />
|
||||
{/if}
|
||||
|
|
|
@ -1,235 +0,0 @@
|
|||
<script>
|
||||
import GoogleLogo from "./_logos/Google.svelte"
|
||||
import { isEqual, cloneDeep } from "lodash/fp"
|
||||
import {
|
||||
Button,
|
||||
Heading,
|
||||
Divider,
|
||||
Label,
|
||||
notifications,
|
||||
Layout,
|
||||
Input,
|
||||
Body,
|
||||
Toggle,
|
||||
Icon,
|
||||
Helpers,
|
||||
Link,
|
||||
} from "@budibase/bbui"
|
||||
import { onMount } from "svelte"
|
||||
import { API } from "api"
|
||||
import { organisation, admin } from "stores/portal"
|
||||
|
||||
const ConfigTypes = {
|
||||
Google: "google",
|
||||
}
|
||||
|
||||
// Some older google configs contain a manually specified value - retain the functionality to edit the field
|
||||
// When there is no value or we are in the cloud - prohibit editing the field, must use platform url to change
|
||||
$: googleCallbackUrl = undefined
|
||||
$: googleCallbackReadonly = $admin.cloud || !googleCallbackUrl
|
||||
|
||||
// Indicate to user that callback is based on platform url
|
||||
// If there is an existing value, indicate that it may be removed to return to default behaviour
|
||||
$: googleCallbackTooltip = $admin.cloud
|
||||
? null
|
||||
: googleCallbackReadonly
|
||||
? "Visit the organisation page to update the platform URL"
|
||||
: "Leave blank to use the default callback URL"
|
||||
$: googleSheetsCallbackUrl = `${$organisation.platformUrl}/api/global/auth/datasource/google/callback`
|
||||
|
||||
$: GoogleConfigFields = {
|
||||
Google: [
|
||||
{ name: "clientID", label: "Client ID" },
|
||||
{ name: "clientSecret", label: "Client secret" },
|
||||
{
|
||||
name: "callbackURL",
|
||||
label: "Callback URL",
|
||||
readonly: googleCallbackReadonly,
|
||||
tooltip: googleCallbackTooltip,
|
||||
placeholder: $organisation.googleCallbackUrl,
|
||||
copyButton: true,
|
||||
},
|
||||
{
|
||||
name: "sheetsURL",
|
||||
label: "Sheets URL",
|
||||
readonly: googleCallbackReadonly,
|
||||
tooltip: googleCallbackTooltip,
|
||||
placeholder: googleSheetsCallbackUrl,
|
||||
copyButton: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
let google
|
||||
|
||||
const providers = { google }
|
||||
|
||||
// control the state of the save button depending on whether form has changed
|
||||
let originalGoogleDoc
|
||||
let googleSaveButtonDisabled
|
||||
$: {
|
||||
isEqual(providers.google?.config, originalGoogleDoc?.config)
|
||||
? (googleSaveButtonDisabled = true)
|
||||
: (googleSaveButtonDisabled = false)
|
||||
}
|
||||
|
||||
$: googleComplete = !!(
|
||||
providers.google?.config?.clientID && providers.google?.config?.clientSecret
|
||||
)
|
||||
|
||||
async function saveConfig(config) {
|
||||
// Delete unsupported fields
|
||||
delete config.createdAt
|
||||
delete config.updatedAt
|
||||
return API.saveConfig(config)
|
||||
}
|
||||
|
||||
async function saveGoogle() {
|
||||
if (!googleComplete) {
|
||||
notifications.error(
|
||||
`Please fill in all required ${ConfigTypes.Google} fields`
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const google = providers.google
|
||||
|
||||
try {
|
||||
const res = await saveConfig(google)
|
||||
providers[res.type]._rev = res._rev
|
||||
providers[res.type]._id = res._id
|
||||
notifications.success(`Settings saved`)
|
||||
} catch (e) {
|
||||
notifications.error(e.message)
|
||||
return
|
||||
}
|
||||
|
||||
googleSaveButtonDisabled = true
|
||||
originalGoogleDoc = cloneDeep(providers.google)
|
||||
}
|
||||
|
||||
const copyToClipboard = async value => {
|
||||
await Helpers.copyToClipboard(value)
|
||||
notifications.success("Copied")
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
await organisation.init()
|
||||
} catch (error) {
|
||||
notifications.error("Error getting org config")
|
||||
}
|
||||
|
||||
// Fetch Google config
|
||||
let googleDoc
|
||||
try {
|
||||
googleDoc = await API.getConfig(ConfigTypes.Google)
|
||||
} catch (error) {
|
||||
notifications.error("Error fetching Google OAuth config")
|
||||
}
|
||||
if (!googleDoc?._id) {
|
||||
providers.google = {
|
||||
type: ConfigTypes.Google,
|
||||
config: { activated: false },
|
||||
}
|
||||
originalGoogleDoc = cloneDeep(googleDoc)
|
||||
} else {
|
||||
// Default activated to true for older configs
|
||||
if (googleDoc.config.activated === undefined) {
|
||||
googleDoc.config.activated = true
|
||||
}
|
||||
originalGoogleDoc = cloneDeep(googleDoc)
|
||||
providers.google = googleDoc
|
||||
}
|
||||
googleCallbackUrl = providers?.google?.config?.callbackURL
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if providers.google}
|
||||
<Divider />
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="S">
|
||||
<div class="provider-title">
|
||||
<GoogleLogo />
|
||||
<span>Google</span>
|
||||
</div>
|
||||
</Heading>
|
||||
<Body size="S">
|
||||
To allow users to authenticate using their Google accounts, fill out the
|
||||
fields below. Read the <Link
|
||||
size="M"
|
||||
href={"https://docs.budibase.com/docs/sso-with-google"}
|
||||
>documentation</Link
|
||||
> for more information.
|
||||
</Body>
|
||||
</Layout>
|
||||
<Layout gap="XS" noPadding>
|
||||
{#each GoogleConfigFields.Google as field}
|
||||
<div class="form-row">
|
||||
<Label size="L" tooltip={field.tooltip}>{field.label}</Label>
|
||||
<div class="inputContainer">
|
||||
<div class="input">
|
||||
<Input
|
||||
bind:value={providers.google.config[field.name]}
|
||||
readonly={field.readonly}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
</div>
|
||||
{#if field.copyButton}
|
||||
<div
|
||||
class="copy"
|
||||
on:click={() => copyToClipboard(field.placeholder)}
|
||||
>
|
||||
<Icon size="S" name="Copy" />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="form-row">
|
||||
<Label size="L">Activated</Label>
|
||||
<Toggle text="" bind:value={providers.google.config.activated} />
|
||||
</div>
|
||||
</Layout>
|
||||
<div>
|
||||
<Button
|
||||
disabled={googleSaveButtonDisabled}
|
||||
cta
|
||||
on:click={() => saveGoogle()}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.form-row {
|
||||
display: grid;
|
||||
grid-template-columns: 120px 1fr;
|
||||
grid-gap: var(--spacing-l);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.provider-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
.provider-title span {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.inputContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.input {
|
||||
flex: 1;
|
||||
}
|
||||
.copy {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import GoogleLogo from "./_logos/Google.svelte"
|
||||
import OidcLogo from "./_logos/OIDC.svelte"
|
||||
import MicrosoftLogo from "assets/microsoft-logo.png"
|
||||
import Auth0Logo from "assets/auth0-logo.png"
|
||||
|
@ -27,9 +28,9 @@
|
|||
import { API } from "api"
|
||||
import { organisation, admin, licensing } from "stores/portal"
|
||||
import Scim from "./scim.svelte"
|
||||
import Google from "./google.svelte"
|
||||
|
||||
const ConfigTypes = {
|
||||
Google: "google",
|
||||
OIDC: "oidc",
|
||||
}
|
||||
|
||||
|
@ -37,6 +38,43 @@
|
|||
|
||||
$: enforcedSSO = $organisation.isSSOEnforced
|
||||
|
||||
// Some older google configs contain a manually specified value - retain the functionality to edit the field
|
||||
// When there is no value or we are in the cloud - prohibit editing the field, must use platform url to change
|
||||
$: googleCallbackUrl = undefined
|
||||
$: googleCallbackReadonly = $admin.cloud || !googleCallbackUrl
|
||||
|
||||
// Indicate to user that callback is based on platform url
|
||||
// If there is an existing value, indicate that it may be removed to return to default behaviour
|
||||
$: googleCallbackTooltip = $admin.cloud
|
||||
? null
|
||||
: googleCallbackReadonly
|
||||
? "Visit the organisation page to update the platform URL"
|
||||
: "Leave blank to use the default callback URL"
|
||||
$: googleSheetsCallbackUrl = `${$organisation.platformUrl}/api/global/auth/datasource/google/callback`
|
||||
|
||||
$: GoogleConfigFields = {
|
||||
Google: [
|
||||
{ name: "clientID", label: "Client ID" },
|
||||
{ name: "clientSecret", label: "Client secret" },
|
||||
{
|
||||
name: "callbackURL",
|
||||
label: "Callback URL",
|
||||
readonly: googleCallbackReadonly,
|
||||
tooltip: googleCallbackTooltip,
|
||||
placeholder: $organisation.googleCallbackUrl,
|
||||
copyButton: true,
|
||||
},
|
||||
{
|
||||
name: "sheetsURL",
|
||||
label: "Sheets URL",
|
||||
readonly: googleCallbackReadonly,
|
||||
tooltip: googleCallbackTooltip,
|
||||
placeholder: googleSheetsCallbackUrl,
|
||||
copyButton: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
$: OIDCConfigFields = {
|
||||
Oidc: [
|
||||
{ name: "configUrl", label: "Config URL" },
|
||||
|
@ -95,9 +133,15 @@
|
|||
const providers = { google, oidc }
|
||||
|
||||
// control the state of the save button depending on whether form has changed
|
||||
let originalGoogleDoc
|
||||
let originalOidcDoc
|
||||
let googleSaveButtonDisabled
|
||||
let oidcSaveButtonDisabled
|
||||
$: {
|
||||
isEqual(providers.google?.config, originalGoogleDoc?.config)
|
||||
? (googleSaveButtonDisabled = true)
|
||||
: (googleSaveButtonDisabled = false)
|
||||
|
||||
// delete the callback url which is never saved to the oidc
|
||||
// config doc, to ensure an accurate comparison
|
||||
delete providers.oidc?.config.configs[0].callbackURL
|
||||
|
@ -107,6 +151,10 @@
|
|||
: (oidcSaveButtonDisabled = false)
|
||||
}
|
||||
|
||||
$: googleComplete = !!(
|
||||
providers.google?.config?.clientID && providers.google?.config?.clientSecret
|
||||
)
|
||||
|
||||
$: oidcComplete = !!(
|
||||
providers.oidc?.config?.configs[0].configUrl &&
|
||||
providers.oidc?.config?.configs[0].clientID &&
|
||||
|
@ -182,6 +230,30 @@
|
|||
originalOidcDoc = cloneDeep(providers.oidc)
|
||||
}
|
||||
|
||||
async function saveGoogle() {
|
||||
if (!googleComplete) {
|
||||
notifications.error(
|
||||
`Please fill in all required ${ConfigTypes.Google} fields`
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const google = providers.google
|
||||
|
||||
try {
|
||||
const res = await saveConfig(google)
|
||||
providers[res.type]._rev = res._rev
|
||||
providers[res.type]._id = res._id
|
||||
notifications.success(`Settings saved`)
|
||||
} catch (e) {
|
||||
notifications.error(e.message)
|
||||
return
|
||||
}
|
||||
|
||||
googleSaveButtonDisabled = true
|
||||
originalGoogleDoc = cloneDeep(providers.google)
|
||||
}
|
||||
|
||||
let defaultScopes = ["profile", "email", "offline_access"]
|
||||
|
||||
const refreshScopes = idx => {
|
||||
|
@ -209,6 +281,29 @@
|
|||
notifications.error("Error getting org config")
|
||||
}
|
||||
|
||||
// Fetch Google config
|
||||
let googleDoc
|
||||
try {
|
||||
googleDoc = await API.getConfig(ConfigTypes.Google)
|
||||
} catch (error) {
|
||||
notifications.error("Error fetching Google OAuth config")
|
||||
}
|
||||
if (!googleDoc?._id) {
|
||||
providers.google = {
|
||||
type: ConfigTypes.Google,
|
||||
config: { activated: false },
|
||||
}
|
||||
originalGoogleDoc = cloneDeep(googleDoc)
|
||||
} else {
|
||||
// Default activated to true for older configs
|
||||
if (googleDoc.config.activated === undefined) {
|
||||
googleDoc.config.activated = true
|
||||
}
|
||||
originalGoogleDoc = cloneDeep(googleDoc)
|
||||
providers.google = googleDoc
|
||||
}
|
||||
googleCallbackUrl = providers?.google?.config?.callbackURL
|
||||
|
||||
// Get the list of user uploaded logos and push it to the dropdown options.
|
||||
// This needs to be done before the config call so they're available when
|
||||
// the dropdown renders.
|
||||
|
@ -300,7 +395,62 @@
|
|||
> before enabling this feature.
|
||||
</Body>
|
||||
</Layout>
|
||||
<Google />
|
||||
{#if providers.google}
|
||||
<Divider />
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="S">
|
||||
<div class="provider-title">
|
||||
<GoogleLogo />
|
||||
<span>Google</span>
|
||||
</div>
|
||||
</Heading>
|
||||
<Body size="S">
|
||||
To allow users to authenticate using their Google accounts, fill out the
|
||||
fields below. Read the <Link
|
||||
size="M"
|
||||
href={"https://docs.budibase.com/docs/sso-with-google"}
|
||||
>documentation</Link
|
||||
> for more information.
|
||||
</Body>
|
||||
</Layout>
|
||||
<Layout gap="XS" noPadding>
|
||||
{#each GoogleConfigFields.Google as field}
|
||||
<div class="form-row">
|
||||
<Label size="L" tooltip={field.tooltip}>{field.label}</Label>
|
||||
<div class="inputContainer">
|
||||
<div class="input">
|
||||
<Input
|
||||
bind:value={providers.google.config[field.name]}
|
||||
readonly={field.readonly}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
</div>
|
||||
{#if field.copyButton}
|
||||
<div
|
||||
class="copy"
|
||||
on:click={() => copyToClipboard(field.placeholder)}
|
||||
>
|
||||
<Icon size="S" name="Copy" />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="form-row">
|
||||
<Label size="L">Activated</Label>
|
||||
<Toggle text="" bind:value={providers.google.config.activated} />
|
||||
</div>
|
||||
</Layout>
|
||||
<div>
|
||||
<Button
|
||||
disabled={googleSaveButtonDisabled}
|
||||
cta
|
||||
on:click={() => saveGoogle()}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
{#if providers.oidc}
|
||||
<Divider />
|
||||
<Layout gap="XS" noPadding>
|
||||
|
|
|
@ -27,7 +27,8 @@ COPY scripts/integrations/oracle/ scripts/integrations/oracle/
|
|||
RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
|
||||
|
||||
COPY package.json .
|
||||
RUN yarn install --frozen-lockfile --production=true
|
||||
COPY dist/yarn.lock .
|
||||
RUN yarn install --production=true
|
||||
# Remove unneeded data from file system to reduce image size
|
||||
RUN yarn cache clean && apt-get remove -y --purge --auto-remove g++ make python \
|
||||
&& rm -rf /tmp/* /root/.node-gyp /usr/local/lib/node_modules/npm/node_modules/node-gyp
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"test": "bash scripts/test.sh",
|
||||
"test:memory": "jest --maxWorkers=2 --logHeapUsage --forceExit",
|
||||
"test:watch": "jest --watch",
|
||||
"predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && yarn build --configuration=production",
|
||||
"predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && yarn build && cp ../../yarn.lock ./dist/",
|
||||
"build:docker": "yarn predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
|
||||
"build:docs": "node ./scripts/docs/generate.js open",
|
||||
"run:docker": "node dist/index.js",
|
||||
|
|
|
@ -11,7 +11,7 @@ import { BuildSchemaErrors, InvalidColumns } from "../../constants"
|
|||
import { getIntegration } from "../../integrations"
|
||||
import { getDatasourceAndQuery } from "./row/utils"
|
||||
import { invalidateDynamicVariables } from "../../threads/utils"
|
||||
import { db as dbCore, context, events, cache } from "@budibase/backend-core"
|
||||
import { db as dbCore, context, events } from "@budibase/backend-core"
|
||||
import {
|
||||
UserCtx,
|
||||
Datasource,
|
||||
|
@ -25,11 +25,9 @@ import {
|
|||
FetchDatasourceInfoResponse,
|
||||
IntegrationBase,
|
||||
DatasourcePlus,
|
||||
SourceName,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../../sdk"
|
||||
import { builderSocket } from "../../websockets"
|
||||
import { setupCreationAuth as googleSetupCreationAuth } from "src/integrations/googlesheets"
|
||||
|
||||
function getErrorTables(errors: any, errorType: string) {
|
||||
return Object.entries(errors)
|
||||
|
@ -308,12 +306,6 @@ export async function update(ctx: UserCtx<any, UpdateDatasourceResponse>) {
|
|||
builderSocket?.emitDatasourceUpdate(ctx, datasource)
|
||||
}
|
||||
|
||||
const preSaveAction: Partial<Record<SourceName, any>> = {
|
||||
[SourceName.GOOGLE_SHEETS]: async (datasource: Datasource) => {
|
||||
await googleSetupCreationAuth(datasource.config as any)
|
||||
},
|
||||
}
|
||||
|
||||
export async function save(
|
||||
ctx: UserCtx<CreateDatasourceRequest, CreateDatasourceResponse>
|
||||
) {
|
||||
|
@ -335,10 +327,6 @@ export async function save(
|
|||
setDefaultDisplayColumns(datasource)
|
||||
}
|
||||
|
||||
if (preSaveAction[datasource.source]) {
|
||||
await preSaveAction[datasource.source](datasource)
|
||||
}
|
||||
|
||||
const dbResp = await db.put(datasource)
|
||||
await events.datasource.created(datasource)
|
||||
datasource._rev = dbResp.rev
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
ConnectionInfo,
|
||||
Datasource,
|
||||
DatasourceFeature,
|
||||
DatasourceFieldType,
|
||||
DatasourcePlus,
|
||||
|
@ -20,15 +19,13 @@ import { OAuth2Client } from "google-auth-library"
|
|||
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
||||
import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"
|
||||
import fetch from "node-fetch"
|
||||
import { cache, configs, context, HTTPError } from "@budibase/backend-core"
|
||||
import { configs, HTTPError } from "@budibase/backend-core"
|
||||
import { dataFilters } from "@budibase/shared-core"
|
||||
import { GOOGLE_SHEETS_PRIMARY_KEY } from "../constants"
|
||||
import sdk from "../sdk"
|
||||
|
||||
interface GoogleSheetsConfig {
|
||||
spreadsheetId: string
|
||||
auth: OAuthClientConfig
|
||||
continueSetupId?: string
|
||||
}
|
||||
|
||||
interface OAuthClientConfig {
|
||||
|
@ -75,7 +72,7 @@ const SCHEMA: Integration = {
|
|||
},
|
||||
datasource: {
|
||||
spreadsheetId: {
|
||||
display: "Spreadsheet URL",
|
||||
display: "Google Sheet URL",
|
||||
type: DatasourceFieldType.STRING,
|
||||
required: true,
|
||||
},
|
||||
|
@ -150,7 +147,6 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
|
||||
async testConnection(): Promise<ConnectionInfo> {
|
||||
try {
|
||||
await setupCreationAuth(this.config)
|
||||
await this.connect()
|
||||
return { connected: true }
|
||||
} catch (e: any) {
|
||||
|
@ -570,18 +566,6 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
}
|
||||
}
|
||||
|
||||
export async function setupCreationAuth(datasouce: GoogleSheetsConfig) {
|
||||
if (datasouce.continueSetupId) {
|
||||
const appId = context.getAppId()
|
||||
const tokens = await cache.get(
|
||||
`datasource:creation:${appId}:google:${datasouce.continueSetupId}`
|
||||
)
|
||||
|
||||
datasouce.auth = tokens.tokens
|
||||
delete datasouce.continueSetupId
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
schema: SCHEMA,
|
||||
integration: GoogleSheetsIntegration,
|
||||
|
|
|
@ -13,7 +13,8 @@ RUN yarn global add pm2
|
|||
|
||||
|
||||
COPY package.json .
|
||||
RUN yarn install --frozen-lockfile --production=true
|
||||
COPY dist/yarn.lock .
|
||||
RUN yarn install --production=true
|
||||
# Remove unneeded data from file system to reduce image size
|
||||
RUN apk del .gyp \
|
||||
&& yarn cache clean
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"run:docker": "node dist/index.js",
|
||||
"debug": "yarn build && node --expose-gc --inspect=9223 dist/index.js",
|
||||
"run:docker:cluster": "pm2-runtime start pm2.config.js",
|
||||
"predocker": "yarn build --configuration=production",
|
||||
"predocker": "yarn build && cp ../../yarn.lock ./dist/",
|
||||
"build:docker": "yarn predocker && docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
||||
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
||||
"dev:builder": "npm run dev:stack:init && rimraf dist/ && nodemon",
|
||||
|
|
|
@ -140,6 +140,7 @@ export const datasourcePreAuth = async (ctx: any, next: any) => {
|
|||
{
|
||||
provider,
|
||||
appId: ctx.query.appId,
|
||||
datasourceId: ctx.query.datasourceId,
|
||||
},
|
||||
Cookie.DatasourceAuth
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue