Merge pull request #11009 from Budibase/fix/oidc-custom-icons-fixed
Fix OIDC Custom Icons
This commit is contained in:
commit
f06cc9359f
|
@ -5,6 +5,7 @@ import {
|
||||||
GoogleInnerConfig,
|
GoogleInnerConfig,
|
||||||
OIDCConfig,
|
OIDCConfig,
|
||||||
OIDCInnerConfig,
|
OIDCInnerConfig,
|
||||||
|
OIDCLogosConfig,
|
||||||
SCIMConfig,
|
SCIMConfig,
|
||||||
SCIMInnerConfig,
|
SCIMInnerConfig,
|
||||||
SettingsConfig,
|
SettingsConfig,
|
||||||
|
@ -191,6 +192,10 @@ export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined {
|
||||||
|
|
||||||
// OIDC
|
// OIDC
|
||||||
|
|
||||||
|
export async function getOIDCLogosDoc(): Promise<OIDCLogosConfig | undefined> {
|
||||||
|
return getConfig<OIDCLogosConfig>(ConfigType.OIDC_LOGOS)
|
||||||
|
}
|
||||||
|
|
||||||
async function getOIDCConfigDoc(): Promise<OIDCConfig | undefined> {
|
async function getOIDCConfigDoc(): Promise<OIDCConfig | undefined> {
|
||||||
return getConfig<OIDCConfig>(ConfigType.OIDC)
|
return getConfig<OIDCConfig>(ConfigType.OIDC)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,9 +99,15 @@
|
||||||
bind:this={button}
|
bind:this={button}
|
||||||
>
|
>
|
||||||
{#if fieldIcon}
|
{#if fieldIcon}
|
||||||
<span class="option-extra icon">
|
{#if !useOptionIconImage}
|
||||||
<Icon size="S" name={fieldIcon} />
|
<span class="option-extra icon">
|
||||||
</span>
|
<Icon size="S" name={fieldIcon} />
|
||||||
|
</span>
|
||||||
|
{:else}
|
||||||
|
<span class="option-extra icon field-icon">
|
||||||
|
<img src={fieldIcon} alt="icon" width="15" height="15" />
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if fieldColour}
|
{#if fieldColour}
|
||||||
<span class="option-extra">
|
<span class="option-extra">
|
||||||
|
@ -311,4 +317,8 @@
|
||||||
max-width: 170px;
|
max-width: 170px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.option-extra.icon.field-icon {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -29,14 +29,13 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$: src = !$oidc.logo
|
$: oidcLogoImageURL = preDefinedIcons[$oidc.logo] ?? $oidc.logo
|
||||||
? OidcLogo
|
$: logoSrc = oidcLogoImageURL ?? OidcLogo
|
||||||
: preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}`
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
<FancyButton
|
<FancyButton
|
||||||
icon={src}
|
icon={logoSrc}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
const url = `/api/global/auth/${$auth.tenantId}/oidc/configs/${$oidc.uuid}`
|
const url = `/api/global/auth/${$auth.tenantId}/oidc/configs/${$oidc.uuid}`
|
||||||
if (samePage) {
|
if (samePage) {
|
||||||
|
|
|
@ -79,6 +79,12 @@ export interface OIDCConfigs {
|
||||||
configs: OIDCInnerConfig[]
|
configs: OIDCInnerConfig[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OIDCLogosInnerConfig {
|
||||||
|
[key: string]: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OIDCLogosConfig extends Config<OIDCLogosInnerConfig> {}
|
||||||
|
|
||||||
export interface OIDCInnerConfig {
|
export interface OIDCInnerConfig {
|
||||||
configUrl: string
|
configUrl: string
|
||||||
clientID: string
|
clientID: string
|
||||||
|
|
|
@ -28,6 +28,7 @@ import {
|
||||||
SSOConfig,
|
SSOConfig,
|
||||||
SSOConfigType,
|
SSOConfigType,
|
||||||
UserCtx,
|
UserCtx,
|
||||||
|
OIDCLogosConfig,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import * as pro from "@budibase/pro"
|
import * as pro from "@budibase/pro"
|
||||||
|
|
||||||
|
@ -280,13 +281,39 @@ export async function save(ctx: UserCtx<Config>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
|
||||||
|
if (!oidcLogos) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oidcLogos.config = Object.keys(oidcLogos.config || {}).reduce(
|
||||||
|
(acc: any, key: string) => {
|
||||||
|
if (!key.endsWith("Etag")) {
|
||||||
|
const etag = oidcLogos.config[`${key}Etag`]
|
||||||
|
const objectStoreUrl = objectStore.getGlobalFileUrl(
|
||||||
|
oidcLogos.type,
|
||||||
|
key,
|
||||||
|
etag
|
||||||
|
)
|
||||||
|
acc[key] = objectStoreUrl
|
||||||
|
} else {
|
||||||
|
acc[key] = oidcLogos.config[key]
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export async function find(ctx: UserCtx) {
|
export async function find(ctx: UserCtx) {
|
||||||
try {
|
try {
|
||||||
// Find the config with the most granular scope based on context
|
// Find the config with the most granular scope based on context
|
||||||
const type = ctx.params.type
|
const type = ctx.params.type
|
||||||
const scopedConfig = await configs.getConfig(type)
|
let scopedConfig = await configs.getConfig(type)
|
||||||
|
|
||||||
if (scopedConfig) {
|
if (scopedConfig) {
|
||||||
|
if (type === ConfigType.OIDC_LOGOS) {
|
||||||
|
enrichOIDCLogos(scopedConfig)
|
||||||
|
}
|
||||||
ctx.body = scopedConfig
|
ctx.body = scopedConfig
|
||||||
} else {
|
} else {
|
||||||
// don't throw an error, there simply is nothing to return
|
// don't throw an error, there simply is nothing to return
|
||||||
|
@ -300,16 +327,21 @@ export async function find(ctx: UserCtx) {
|
||||||
export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
|
export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
|
||||||
try {
|
try {
|
||||||
// Find the config with the most granular scope based on context
|
// Find the config with the most granular scope based on context
|
||||||
const config = await configs.getOIDCConfig()
|
const oidcConfig = await configs.getOIDCConfig()
|
||||||
|
const oidcCustomLogos = await configs.getOIDCLogosDoc()
|
||||||
|
|
||||||
if (!config) {
|
if (oidcCustomLogos) {
|
||||||
|
enrichOIDCLogos(oidcCustomLogos)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!oidcConfig) {
|
||||||
ctx.body = []
|
ctx.body = []
|
||||||
} else {
|
} else {
|
||||||
ctx.body = [
|
ctx.body = [
|
||||||
{
|
{
|
||||||
logo: config.logo,
|
logo: oidcCustomLogos?.config[oidcConfig.logo] ?? oidcConfig.logo,
|
||||||
name: config.name,
|
name: oidcConfig.name,
|
||||||
uuid: config.uuid,
|
uuid: oidcConfig.uuid,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue