mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-28 00:02:42 +00:00
* feat: mask oauth client secret in instance settings * fix: address ci review - migrate nextcloud + use Password small prop * fix: associate client secret labels with input via for/id
98 lines
3.0 KiB
Svelte
98 lines
3.0 KiB
Svelte
<script lang="ts">
|
|
import { run } from 'svelte/legacy'
|
|
|
|
import IconedResourceType from './IconedResourceType.svelte'
|
|
import TextInput from './text_input/TextInput.svelte'
|
|
import Password from './Password.svelte'
|
|
import Toggle from './Toggle.svelte'
|
|
import SettingCard from './instanceSettings/SettingCard.svelte'
|
|
|
|
interface Props {
|
|
value: any
|
|
}
|
|
|
|
let { value = $bindable() }: Props = $props()
|
|
|
|
const AUTH_URL_SUFFIX = '/ui/oauth2'
|
|
|
|
let proxyUrlValue = $state(undefined)
|
|
|
|
function changeValues({ baseUrl, id }) {
|
|
if (value) {
|
|
value = {
|
|
...value,
|
|
connect_config: {
|
|
auth_url: `${baseUrl}${AUTH_URL_SUFFIX}`,
|
|
token_url: `${baseUrl}/oauth2/token`,
|
|
scopes: ['openid', 'profile', 'email']
|
|
},
|
|
login_config: {
|
|
auth_url: `${baseUrl}${AUTH_URL_SUFFIX}`,
|
|
token_url: `${baseUrl}/oauth2/token`,
|
|
userinfo_url: `${baseUrl}/oauth2/openid/${id}/userinfo`,
|
|
scopes: ['openid', 'profile', 'email']
|
|
}
|
|
}
|
|
|
|
proxyUrlValue = baseUrl
|
|
}
|
|
}
|
|
let enabled = $derived(value != undefined)
|
|
// If `baseUrl` is not already set in the form, try to parse it from the `auth_url` value
|
|
//
|
|
// The binding dance here allows us to avoid rendering the string 'undefined' in the input, and
|
|
// also allow lazy/async binding of the `value` prop.
|
|
let derivedBaseUrl = $derived(value?.connect_config?.auth_url?.replace(AUTH_URL_SUFFIX, ''))
|
|
let baseUrl = $derived(proxyUrlValue ?? derivedBaseUrl ?? '')
|
|
run(() => {
|
|
changeValues({ baseUrl, id: value?.id ?? '' })
|
|
})
|
|
</script>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
<!-- svelte-ignore a11y_label_has_associated_control -->
|
|
<label class="text-xs font-semibold text-emphasis flex gap-4 items-center"
|
|
><div class="w-[120px]"><IconedResourceType name={'kanidm'} after={true} /></div><Toggle
|
|
checked={enabled}
|
|
on:change={(e) => {
|
|
if (e.detail) {
|
|
value = { id: '', secret: '' }
|
|
} else {
|
|
value = undefined
|
|
}
|
|
}}
|
|
/></label
|
|
>
|
|
{#if enabled}
|
|
<SettingCard class="flex flex-col gap-6">
|
|
<label class="flex flex-col gap-1">
|
|
<span class="text-emphasis font-semibold text-xs">Kanidm Url</span>
|
|
<span class="text-secondary font-normal text-xs">{'KANIDM_URL/ui/oauth2'}</span>
|
|
<TextInput inputProps={{ type: 'text', placeholder: 'Base URL' }} bind:value={baseUrl} />
|
|
</label>
|
|
<label class="flex flex-col gap-1">
|
|
<span class="text-emphasis font-semibold text-xs">Custom Name</span>
|
|
<TextInput
|
|
inputProps={{ type: 'text', placeholder: 'Custom Name' }}
|
|
bind:value={value['display_name']}
|
|
/>
|
|
</label>
|
|
<label class="flex flex-col gap-1">
|
|
<span class="text-emphasis font-semibold text-xs">Client Id</span>
|
|
<TextInput
|
|
inputProps={{ type: 'text', placeholder: 'Client Id' }}
|
|
bind:value={value['id']}
|
|
/>
|
|
</label>
|
|
<label for="kanidm_client_secret" class="flex flex-col gap-1">
|
|
<span class="text-emphasis font-semibold text-xs">Client Secret </span>
|
|
<Password
|
|
id="kanidm_client_secret"
|
|
placeholder="Client Secret"
|
|
bind:password={value['secret']}
|
|
/>
|
|
</label>
|
|
</SettingCard>
|
|
{/if}
|
|
</div>
|