feat: add setup details to oidc client details

This commit is contained in:
Elias Schneider
2024-09-03 22:24:29 +02:00
parent e7861df95a
commit fd21ce5aac
3 changed files with 67 additions and 33 deletions

View File

@@ -23,7 +23,7 @@
<Avatar.Fallback>{initials}</Avatar.Fallback> <Avatar.Fallback>{initials}</Avatar.Fallback>
</Avatar.Root></DropdownMenu.Trigger </Avatar.Root></DropdownMenu.Trigger
> >
<DropdownMenu.Content class="w-40" align="start"> <DropdownMenu.Content class="min-w-40" align="start">
<DropdownMenu.Label class="font-normal"> <DropdownMenu.Label class="font-normal">
<div class="flex flex-col space-y-1"> <div class="flex flex-col space-y-1">
<p class="text-sm font-medium leading-none"> <p class="text-sm font-medium leading-none">

View File

@@ -23,24 +23,26 @@
<section> <section>
<div class="h-screen w-full"> <div class="h-screen w-full">
<main class="flex min-h-screen flex-1 flex-col gap-4 bg-muted/40 p-4 md:gap-8 md:p-10"> <main class="bg-muted/40 flex min-h-screen flex-col gap-x-4 gap-y-10 p-4 md:p-10 lg:flex-row">
<div>
<div class="mx-auto grid w-full max-w-[1440px] gap-2"> <div class="mx-auto grid w-full max-w-[1440px] gap-2">
<h1 class="text-3xl font-semibold">Settings</h1> <h1 class="mb-5 text-3xl font-semibold">Settings</h1>
</div> </div>
<div <div
class="mx-auto grid w-full max-w-[1440px] items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]" class="mx-auto grid w-full max-w-[1440px] items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]"
> >
<nav class="grid gap-4 text-sm text-muted-foreground"> <nav class="text-muted-foreground grid gap-4 text-sm">
{#each links as { href, label }} {#each links as { href, label }}
<a {href} class={$page.url.pathname.startsWith(href) ? 'font-bold text-primary' : ''}> <a {href} class={$page.url.pathname.startsWith(href) ? 'text-primary font-bold' : ''}>
{label} {label}
</a> </a>
{/each} {/each}
</nav> </nav>
<div class="flex flex-col gap-5">
{@render children()}
</div> </div>
</div> </div>
<div class="flex w-full flex-col gap-5">
{@render children()}
</div>
</main> </main>
</div> </div>
</section> </section>

View File

@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { beforeNavigate } from '$app/navigation'; import { beforeNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { openConfirmDialog } from '$lib/components/confirm-dialog'; import { openConfirmDialog } from '$lib/components/confirm-dialog';
import { Button } from '$lib/components/ui/button'; import { Button } from '$lib/components/ui/button';
import * as Card from '$lib/components/ui/card'; import * as Card from '$lib/components/ui/card';
@@ -10,13 +11,24 @@
import { axiosErrorToast } from '$lib/utils/error-util'; import { axiosErrorToast } from '$lib/utils/error-util';
import { LucideChevronLeft, LucideRefreshCcw } from 'lucide-svelte'; import { LucideChevronLeft, LucideRefreshCcw } from 'lucide-svelte';
import { toast } from 'svelte-sonner'; import { toast } from 'svelte-sonner';
import { slide } from 'svelte/transition';
import OidcForm from '../oidc-client-form.svelte'; import OidcForm from '../oidc-client-form.svelte';
let { data } = $props(); let { data } = $props();
let client = $state(data); let client = $state(data);
let showAllDetails = $state(false);
const oidcService = new OidcService(); const oidcService = new OidcService();
const setupDetails = {
'Authorization URL': `https://${$page.url.hostname}/authorize`,
'OIDC Discovery URL': `https://${$page.url.hostname}/.well-known/openid-configuration`,
'Token URL': `https://${$page.url.hostname}/api/oidc/token`,
'Userinfo URL': `https://${$page.url.hostname}/api/oidc/userinfo`,
'Certificate URL': `https://${$page.url.hostname}/.well-known/jwks.json`,
PKCE: 'Disabled'
};
async function updateClient(updatedClient: OidcClientCreateWithLogo) { async function updateClient(updatedClient: OidcClientCreateWithLogo) {
let success = true; let success = true;
const dataPromise = oidcService.updateClient(client.id, updatedClient); const dataPromise = oidcService.updateClient(client.id, updatedClient);
@@ -74,12 +86,13 @@
<Card.Title>{client.name}</Card.Title> <Card.Title>{client.name}</Card.Title>
</Card.Header> </Card.Header>
<Card.Content> <Card.Content>
<div class="flex"> <div class="flex flex-col">
<div class="mb-2 flex">
<Label class="mb-0 w-44">Client ID</Label> <Label class="mb-0 w-44">Client ID</Label>
<span class="text-muted-foreground text-sm" data-testid="client-id"> {client.id}</span> <span class="text-muted-foreground text-sm" data-testid="client-id"> {client.id}</span>
</div> </div>
<div class="mt-3 flex items-center"> <div class="mb-2 mt-1 flex items-center">
<Label class="mb-0 w-44">Client secret</Label> <Label class="w-44">Client secret</Label>
<span class="text-muted-foreground text-sm" data-testid="client-secret" <span class="text-muted-foreground text-sm" data-testid="client-secret"
>{$clientSecretStore ?? '••••••••••••••••••••••••••••••••'}</span >{$clientSecretStore ?? '••••••••••••••••••••••••••••••••'}</span
> >
@@ -93,6 +106,25 @@
> >
{/if} {/if}
</div> </div>
{#if showAllDetails}
<div transition:slide>
{#each Object.entries(setupDetails) as [key, value]}
<div class="mb-5 flex">
<Label class="mb-0 w-44">{key}</Label>
<span class="text-muted-foreground text-sm">{value}</span>
</div>
{/each}
</div>
{/if}
{#if !showAllDetails}
<div class="mt-4 flex justify-center">
<Button on:click={() => (showAllDetails = true)} size="sm" variant="ghost"
>Show more details</Button
>
</div>
{/if}
</div>
</Card.Content> </Card.Content>
</Card.Root> </Card.Root>
<Card.Root> <Card.Root>