Fix bug where OIDC icon was not being displayed due to misconfiguration

This commit is contained in:
Peter Clement 2021-07-09 14:18:03 +01:00
parent 38a00ba50e
commit 4ae29f6b54
5 changed files with 23 additions and 20 deletions

View File

@ -31,7 +31,6 @@
} }
open = true open = true
} }
console.log(fieldIcon)
</script> </script>
<button <button

View File

@ -18,7 +18,6 @@
AD: MicrosoftLogo AD: MicrosoftLogo
} }
$: show = $admin.checklist?.oidc $: show = $admin.checklist?.oidc
console.log(preDefinedIcons[oidcIcon])
</script> </script>
{#if show} {#if show}

View File

@ -19,8 +19,6 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { onMount } from "svelte" import { onMount } from "svelte"
import api from "builderStore/api" import api from "builderStore/api"
import { writable } from "svelte/store"
import { organisation } from "stores/portal"
const ConfigTypes = { const ConfigTypes = {
Google: "google", Google: "google",
@ -41,12 +39,12 @@
} }
const OIDCConfigFields = { const OIDCConfigFields = {
Oidc: ["configUrl", "clientId", "clientSecret"], Oidc: ["configUrl", "clientID", "clientSecret"],
} }
const OIDCConfigLabels = { const OIDCConfigLabels = {
Oidc: { Oidc: {
configUrl: "Config URL", configUrl: "Config URL",
clientId: "Client ID", clientID: "Client ID",
clientSecret: "Client Secret", clientSecret: "Client Secret",
}, },
} }

View File

@ -111,15 +111,24 @@ exports.publicSettings = async function (ctx) {
const oidcConfig = await getScopedFullConfig(db, { const oidcConfig = await getScopedFullConfig(db, {
type: Configs.OIDC, type: Configs.OIDC,
}) })
if (!publicConfig) {
ctx.body = {} if (publicConfig && !oidcConfig) {
} else {
ctx.body = publicConfig ctx.body = publicConfig
if (oidcConfig.config) {
publicConfig.config.oidcIcon = oidcConfig.config.iconName
publicConfig.config.oidcName = oidcConfig.config.name
}
} }
else if(!publicConfig && oidcConfig) {
// Pull out the OIDC icon and name because the other properties shouldn't
// be made public
let config = {}
config.oidcIcon = oidcConfig.config.iconName
config.oidcName = oidcConfig.config.name
oidcConfig.config = config
ctx.body = oidcConfig
}
else if (publicConfig && oidcConfig) {
ctx.body = publicConfig
publicConfig.config.oidcIcon = oidcConfig.config.iconName
publicConfig.config.oidcName = oidcConfig.config.name
}
} catch (err) { } catch (err) {
ctx.throw(err.status, err) ctx.throw(err.status, err)
} }

View File

@ -3,7 +3,7 @@ const controller = require("../../controllers/admin/configs")
const joiValidator = require("../../../middleware/joi-validator") const joiValidator = require("../../../middleware/joi-validator")
const adminOnly = require("../../../middleware/adminOnly") const adminOnly = require("../../../middleware/adminOnly")
const Joi = require("joi") const Joi = require("joi")
const { Configs, ConfigUploads } = require("../../../constants") const { Configs } = require("../../../constants")
const router = Router() const router = Router()
@ -41,16 +41,14 @@ function googleValidation() {
}).unknown(true) }).unknown(true)
} }
function OidcValidation() { function oidcValidation() {
// prettier-ignore // prettier-ignore
return Joi.object({ return Joi.object({
clientID: Joi.string().required(), clientID: Joi.string().required(),
authUrl: Joi.string().required(),
tokenUrl: Joi.string().required(),
userInfoUrl: Joi.string().required(),
clientId: Joi.string().required(),
clientSecret: Joi.string().required(), clientSecret: Joi.string().required(),
callbackUrl: Joi.string().required(), configUrl: Joi.string().required(),
iconName: Joi.string().required(),
name: Joi.string().required(),
}).unknown(true) }).unknown(true)
} }