From 904ce293152656bc833411a56ef09aec3275eaf1 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 5 Jul 2021 14:24:13 +0100 Subject: [PATCH 1/5] Front End form for OIDC configuration --- .../portal/manage/auth/_logos/OIDC.svelte | 20 +++ .../builder/portal/manage/auth/index.svelte | 138 ++++++++++++++---- 2 files changed, 132 insertions(+), 26 deletions(-) create mode 100644 packages/builder/src/pages/builder/portal/manage/auth/_logos/OIDC.svelte diff --git a/packages/builder/src/pages/builder/portal/manage/auth/_logos/OIDC.svelte b/packages/builder/src/pages/builder/portal/manage/auth/_logos/OIDC.svelte new file mode 100644 index 0000000000..f56d716ae0 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/auth/_logos/OIDC.svelte @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte index 86137fddf8..ce30e5f2f1 100644 --- a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte @@ -1,5 +1,6 @@ @@ -74,7 +128,7 @@ below. - {#if google} + {#if providers.google} @@ -89,17 +143,50 @@ - {#each ConfigFields.Google as field} + {#each GoogleConfigFields.Google as field}
- - + +
{/each}
-
- -
{/if} + {#if providers.oidc} + + + + + + OpenID Connect + + + + To allow users to authenticate using OIDC, fill out the fields below. + + + + {#each OIDCConfigFields.Oidc as field} +
+ + +
+ {/each} + + To customize your login button, fill out the fields below. + +
+ +
{/each} +
- To customize your login button, fill out the fields below. + To customize your login button, fill out the fields below.
- - +
+
+ -
+ onFileSelected(e)} + bind:this={fileinput} + />
{/if}
- +
@@ -201,4 +251,8 @@ align-items: center; gap: var(--spacing-s); } + + input { + display: none; + } diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index ffd85e98e9..2f62af18bb 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -146,7 +146,7 @@ exports.upload = async function (ctx) { } } const url = `/${bucket}/${key}` - cfgStructure.config[`${name}Url`] = url + cfgStructure.config[`${name}`] = url // write back to db with url updated await db.put(cfgStructure) @@ -192,8 +192,6 @@ exports.configChecklist = async function (ctx) { const oidcConfig = await getScopedFullConfig(db, { type: Configs.OIDC, }) - - // They have set up an admin user const users = await db.allDocs( getGlobalUserParams(null, { diff --git a/packages/worker/src/api/routes/admin/configs.js b/packages/worker/src/api/routes/admin/configs.js index 83eec20cf3..2e926b61f0 100644 --- a/packages/worker/src/api/routes/admin/configs.js +++ b/packages/worker/src/api/routes/admin/configs.js @@ -79,7 +79,7 @@ function buildUploadValidation() { // prettier-ignore return joiValidator.params(Joi.object({ type: Joi.string().valid(...Object.values(Configs)).required(), - name: Joi.string().valid(...Object.values(ConfigUploads)).required(), + name: Joi.string().required(), }).required()) } diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index 70c61cd6b0..ae52af9d7f 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -16,7 +16,7 @@ exports.Configs = Configs exports.ConfigUploads = { LOGO: "logo", - OIDC_LOGO: "oidc_logo" + OIDC_LOGO: "oidc_logo", } const TemplateTypes = { From 8426ffc036f5d025629397f900c22f8324f6b46f Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 7 Jul 2021 16:18:18 +0100 Subject: [PATCH 4/5] Fix for icon upload issue --- packages/auth/src/constants.js | 2 +- packages/bbui/src/Form/Core/Picker.svelte | 3 +- .../builder/portal/manage/auth/index.svelte | 37 ++++++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/auth/src/constants.js b/packages/auth/src/constants.js index ca0e69b34a..54736bed67 100644 --- a/packages/auth/src/constants.js +++ b/packages/auth/src/constants.js @@ -21,5 +21,5 @@ exports.Configs = { SMTP: "smtp", GOOGLE: "google", OIDC: "oidc", - OIDC_LOGOS:"oidc_logos" + OIDC_LOGOS: "oidc_logos", } diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index b7f53fb861..cd8f784b14 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -14,7 +14,6 @@ export let isPlaceholder = false export let placeholderOption = null export let options = [] - export let callbackOptionValue = null export let isOptionSelected = () => false export let onSelectOption = () => {} export let getOptionLabel = option => option @@ -47,7 +46,7 @@ > {#if fieldIcon} - test + OpenID Icon {/if} diff --git a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte index b5fd01b361..1b74e9aaac 100644 --- a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte @@ -1,5 +1,5 @@ @@ -215,12 +225,11 @@
- Date: Wed, 7 Jul 2021 17:39:26 +0100 Subject: [PATCH 5/5] Add OIDC icon to login page --- .../auth/_components/OidcButton.svelte | 39 +++++++++++++++++++ .../src/pages/builder/auth/login.svelte | 2 + .../src/api/controllers/admin/configs.js | 1 + 3 files changed, 42 insertions(+) create mode 100644 packages/builder/src/pages/builder/auth/_components/OidcButton.svelte diff --git a/packages/builder/src/pages/builder/auth/_components/OidcButton.svelte b/packages/builder/src/pages/builder/auth/_components/OidcButton.svelte new file mode 100644 index 0000000000..46990b759e --- /dev/null +++ b/packages/builder/src/pages/builder/auth/_components/OidcButton.svelte @@ -0,0 +1,39 @@ + + + {#if show} + window.open("/api/admin/auth/oidc", "_blank")} + > +
+ oidc icon +

Sign in with OIDC

+
+
+ {/if} + + + \ No newline at end of file diff --git a/packages/builder/src/pages/builder/auth/login.svelte b/packages/builder/src/pages/builder/auth/login.svelte index 9fb984c73e..264962f3fa 100644 --- a/packages/builder/src/pages/builder/auth/login.svelte +++ b/packages/builder/src/pages/builder/auth/login.svelte @@ -12,6 +12,7 @@ import { goto, params } from "@roxi/routify" import { auth, organisation } from "stores/portal" import GoogleButton from "./_components/GoogleButton.svelte" + import OidcButton from "./_components/OidcButton.svelte" import Logo from "assets/bb-emblem.svg" import { onMount } from "svelte" @@ -61,6 +62,7 @@ Sign in to {company} + Sign in with email diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index 2f62af18bb..d83be15667 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -205,6 +205,7 @@ exports.configChecklist = async function (ctx) { smtp: !!smtpConfig, adminUser, oauth: !!oauthConfig, + oidc: !!oidcConfig, } } catch (err) { ctx.throw(err.status, err)