diff --git a/packages/builder/src/components/integration/RestQueryViewer.svelte b/packages/builder/src/components/integration/RestQueryViewer.svelte index 5fa77ea5d6..178032ac35 100644 --- a/packages/builder/src/components/integration/RestQueryViewer.svelte +++ b/packages/builder/src/components/integration/RestQueryViewer.svelte @@ -684,6 +684,7 @@ diff --git a/packages/builder/src/components/integration/rest/AuthPicker.svelte b/packages/builder/src/components/integration/rest/AuthPicker.svelte index 2b4cb1416a..3e93fbecbf 100644 --- a/packages/builder/src/components/integration/rest/AuthPicker.svelte +++ b/packages/builder/src/components/integration/rest/AuthPicker.svelte @@ -3,21 +3,36 @@ ActionButton, Body, Button, + Divider, List, ListItem, PopoverAlignment, } from "@budibase/bbui" import { goto } from "@roxi/routify" - import { appStore } from "@/stores/builder" + import { appStore, oauth2 } from "@/stores/builder" import DetailPopover from "@/components/common/DetailPopover.svelte" + import { featureFlag } from "@/helpers" + import { FeatureFlag, RestAuthType } from "@budibase/types" + import { onMount } from "svelte" + + type Config = { label: string; value: string } export let authConfigId: string | undefined - export let authConfigs: { label: string; value: string }[] + export let authConfigType: RestAuthType | undefined + export let authConfigs: Config[] export let datasourceId: string let popover: DetailPopover + let allConfigs: Config[] - $: authConfig = authConfigs.find(c => c.value === authConfigId) + $: allConfigs = [ + ...authConfigs, + ...$oauth2.configs.map(c => ({ + label: c.name, + value: c.id, + })), + ] + $: authConfig = allConfigs.find(c => c.value === authConfigId) function addBasicConfiguration() { $goto( @@ -25,16 +40,28 @@ ) } - function selectConfiguration(id: string) { + function addOAuth2Configuration() { + $goto(`/builder/app/${$appStore.appId}/settings/oauth2`) + } + + function selectConfiguration(id: string, type?: RestAuthType) { if (authConfigId === id) { authConfigId = undefined + authConfigType = undefined } else { authConfigId = id + authConfigType = type } popover.hide() } $: title = !authConfig ? "Authentication" : `Auth: ${authConfig.label}` + + $: oauth2Enabled = featureFlag.isEnabled(FeatureFlag.OAUTH2_CONFIG) + + onMount(() => { + oauth2.fetch() + }) @@ -68,4 +95,29 @@ >Add config + + {#if oauth2Enabled} + + + + OAuth 2.0 (Token-Based Authentication) + + + {#if $oauth2.configs.length} + + {#each $oauth2.configs as config} + selectConfiguration(config.id, RestAuthType.OAUTH2)} + selected={config.id === authConfigId} + /> + {/each} + + {/if} +
+ +
+ {/if}