Merge branch 'feature/oidc-support' of github.com:Budibase/budibase into feature/oidc-support

This commit is contained in:
Rory Powell 2021-07-15 16:21:03 +01:00
commit 806957e462
4 changed files with 28 additions and 10 deletions

View File

@ -1,11 +1,10 @@
<script>
import { ActionButton } from "@budibase/bbui"
import GoogleLogo from "assets/google-logo.png"
import { admin } from "stores/portal"
import { organisation } from "stores/portal"
let show = false
$: show = $admin.checklist?.oauth
$: show = $organisation.google
console.log(show)
</script>
{#if show}

View File

@ -4,10 +4,10 @@
import Auth0Logo from "assets/auth0-logo.png"
import MicrosoftLogo from "assets/microsoft-logo.png"
import { oidc } from "stores/portal"
import { oidc, organisation } from "stores/portal"
import { onMount } from "svelte"
let show = false
$: show = $organisation.oidc
let preDefinedIcons = {
Oidc: OidcLogo,
@ -19,7 +19,6 @@
await oidc.init()
})
$: show = $admin.checklist?.oidc
$: src = !$oidc.logo
? OidcLogo
: preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}`

View File

@ -6,6 +6,8 @@ const DEFAULT_CONFIG = {
logoUrl: undefined,
docsUrl: undefined,
company: "Budibase",
oidc: undefined,
google: undefined,
}
export function createOrganisationStore() {
@ -15,7 +17,7 @@ export function createOrganisationStore() {
async function init() {
const res = await api.get(`/api/admin/configs/public`)
const json = await res.json()
console.log(json)
if (json.status === 400) {
set(DEFAULT_CONFIG)
} else {

View File

@ -125,16 +125,34 @@ exports.publicOidc = async function (ctx) {
exports.publicSettings = async function (ctx) {
const db = new CouchDB(GLOBAL_DB)
let config = {}
try {
// Find the config with the most granular scope based on context
const publicConfig = await getScopedFullConfig(db, {
type: Configs.SETTINGS,
})
if (!publicConfig) {
const googleConfig = await getScopedFullConfig(db, {
type: Configs.GOOGLE,
})
const oidcConfig = await getScopedFullConfig(db, {
type: Configs.OIDC,
})
// Slightly complex logic here to deal with the fact that
// oidc / google might be enabled but org name etc (publicConfig) might not
if (publicConfig && !!googleConfig && !!oidcConfig) {
ctx.body = publicConfig
} else if (!publicConfig && !!googleConfig && !!oidcConfig) {
ctx.body = {}
} else {
ctx.body = publicConfig
if (publicConfig) {
config.config = publicConfig.config
}
config.config.oidc = !!oidcConfig
config.config.google = !!googleConfig
ctx.body = config
}
} catch (err) {
ctx.throw(err.status, err)