Skip to content

Modern Docker Management, Designed for Everyone

fix: make onboardin security settings page the same as the normal settings page

Kyle Mendell20800efb47ec
diff --git a/frontend/src/routes/onboarding/security/+page.svelte b/frontend/src/routes/onboarding/security/+page.svelte
index f8de1c96f..ca1e1e5f2 100644
--- a/frontend/src/routes/onboarding/security/+page.svelte
+++ b/frontend/src/routes/onboarding/security/+page.svelte
@@ -1,52 +1,154 @@
<script lang="ts">
- import { Button } from '$lib/components/ui/button';
+ import type { PageData } from './$types';
import * as Card from '$lib/components/ui/card';
+ import { Button } from '$lib/components/ui/button';
import { Input } from '$lib/components/ui/input';
- import { Label } from '$lib/components/ui/label';
- import * as Select from '$lib/components/ui/select';
import { Switch } from '$lib/components/ui/switch';
- import { settingsAPI } from '$lib/services/api';
+ import { Label } from '$lib/components/ui/label';
+ import { Loader2, Lock, Key, AlertTriangle, Info } from '@lucide/svelte';
+ import OidcConfigDialog from '$lib/components/dialogs/oidc-config-dialog.svelte';
import { toast } from 'svelte-sonner';
import { goto } from '$app/navigation';
- import { Loader2 } from '@lucide/svelte';
+ import { invalidateAll } from '$app/navigation';
+ import { settingsAPI } from '$lib/services/api';
import settingsStore from '$lib/stores/config-store';
+ import type { Settings } from '$lib/types/settings.type';
+
+ let { data }: { data: PageData } = $props();
- let { data } = $props();
let currentSettings = $state(data.settings);
- let isLoading = $state(false);
+ // OIDC dialog state and form
+ let showOidcConfigDialog = $state(false);
+ let oidcConfigForm = $state({
+ clientId: '',
+ clientSecret: '',
+ issuerUrl: '',
+ scopes: 'openid email profile'
+ });
+
+ // Page state mirrors the main Security Settings page
+ let localAuthEnabled = $state(true);
+ let oidcEnabled = $state(false);
+ let sessionTimeout = $state(60); // minutes, to match settings page
+ let passwordPolicy = $state('strong');
+
+ let isLoading = $state({ saving: false });
+
+ let isOidcViewMode = $derived(data.oidcStatus?.envForced && data.oidcStatus?.envConfigured);
+
+ $effect(() => {
+ // Initialize state from currentSettings
+ localAuthEnabled = currentSettings.authLocalEnabled ?? true;
+ oidcEnabled = currentSettings.authOidcEnabled ?? false;
+ // Keep the same unit as the Security Settings page (minutes)
+ sessionTimeout = currentSettings.authSessionTimeout ?? 60;
+ passwordPolicy = currentSettings.authPasswordPolicy ?? 'strong';
- let securitySettings = $state({
- authType: 'local',
- oidcIssuerUrl: '',
- oidcClientId: '',
- oidcClientSecret: '',
- oidcScopes: 'openid email profile',
- sessionTimeout: '24'
+ // Parse OIDC config if present (do not persist clientSecret in state)
+ if (currentSettings.authOidcConfig) {
+ try {
+ const cfg = JSON.parse(currentSettings.authOidcConfig);
+ oidcConfigForm.clientId = cfg.clientId || '';
+ oidcConfigForm.issuerUrl = cfg.issuerUrl || '';
+ oidcConfigForm.scopes = cfg.scopes || 'openid email profile';
+ } catch (e) {
+ console.warn('Failed to parse OIDC config:', e);
+ }
+ }
+ oidcConfigForm.clientSecret = '';
});
- async function handleNext() {
- isLoading = true;
+ async function updateSettingsConfig(updated: Partial<Settings>) {
+ try {
+ currentSettings = await settingsAPI.updateSettings({
+ ...currentSettings,
+ ...updated
+ });
+ settingsStore.set(currentSettings);
+ settingsStore.reload();
+ } catch (error) {
+ console.error('Error updating settings:', error);
+ throw error;
+ }
+ }
+
+ function handleOidcSwitchChange(checked: boolean) {
+ oidcEnabled = checked;
+ if (checked && !data.oidcStatus?.envForced && !data.oidcStatus?.effectivelyConfigured) {
+ showOidcConfigDialog = true;
+ }
+ }
+ function openOidcDialog() {
+ if (!isOidcViewMode) {
+ if (currentSettings.authOidcConfig) {
+ try {
+ const cfg = JSON.parse(currentSettings.authOidcConfig);
+ oidcConfigForm.clientId = cfg.clientId || '';
+ oidcConfigForm.issuerUrl = cfg.issuerUrl || '';
+ oidcConfigForm.scopes = cfg.scopes || 'openid email profile';
+ } catch (e) {
+ console.warn('Failed to parse OIDC config:', e);
+ }
+ }
+ oidcConfigForm.clientSecret = '';
+ }
+ showOidcConfigDialog = true;
+ }
+
+ async function handleSaveOidcConfig() {
try {
- let authOidcConfig = '';
- if (securitySettings.authType === 'oidc') {
- authOidcConfig = JSON.stringify({
- clientId: securitySettings.oidcClientId,
- clientSecret: securitySettings.oidcClientSecret,
- issuerUrl: securitySettings.oidcIssuerUrl,
- scopes: securitySettings.oidcScopes
+ isLoading.saving = true;
+ oidcEnabled = true;
+
+ const oidcConfigString = JSON.stringify({
+ clientId: oidcConfigForm.clientId,
+ clientSecret: oidcConfigForm.clientSecret || '',
+ issuerUrl: oidcConfigForm.issuerUrl,
+ scopes: oidcConfigForm.scopes
+ });
+
+ // Save security changes (no onboarding step change here; Next handles that)
+ await updateSettingsConfig({
+ authLocalEnabled: localAuthEnabled,
+ authOidcEnabled: true,
+ authSessionTimeout: sessionTimeout,
+ authPasswordPolicy: passwordPolicy,
+ authOidcConfig: oidcConfigString
+ });
+
+ toast.success('OIDC configuration saved.');
+ showOidcConfigDialog = false;
+ await invalidateAll();
+ } catch (error) {
+ console.error('Failed to save OIDC configuration:', error);
+ toast.error('Failed to save OIDC configuration.');
+ } finally {
+ isLoading.saving = false;
+ }
+ }
+
+ async function handleNext() {
+ isLoading.saving = true;
+ try {
+ let oidcConfigString = currentSettings.authOidcConfig;
+ if (oidcEnabled && !data.oidcStatus?.envForced) {
+ oidcConfigString = JSON.stringify({
+ clientId: oidcConfigForm.clientId,
+ clientSecret: oidcConfigForm.clientSecret || '',
+ issuerUrl: oidcConfigForm.issuerUrl,
+ scopes: oidcConfigForm.scopes
});
}
- const updatedSettings = await settingsAPI.updateSettings({
- ...currentSettings,
- authLocalEnabled: securitySettings.authType === 'local',
- authOidcEnabled: securitySettings.authType === 'oidc',
- authSessionTimeout: parseInt(securitySettings.sessionTimeout) * 3600,
- authPasswordPolicy: 'strong',
- authRbacEnabled: false,
- authOidcConfig: authOidcConfig,
+ // Save security settings similar to the main page AND mark onboarding step
+ await updateSettingsConfig({
+ authLocalEnabled: localAuthEnabled,
+ authOidcEnabled: oidcEnabled,
+ authSessionTimeout: sessionTimeout,
+ authPasswordPolicy: passwordPolicy,
+ authOidcConfig: oidcConfigString,
onboardingCompleted: false,
onboardingSteps: {
...currentSettings.onboardingSteps,
@@ -54,149 +156,227 @@
}
});
- currentSettings = updatedSettings;
- settingsStore.set(updatedSettings);
-
goto('/onboarding/settings');
} catch (error) {
toast.error('Failed to save security settings');
} finally {
- isLoading = false;
+ isLoading.saving = false;
}
}
+ function handleBack() {
+ goto('/onboarding/docker');
+ }
+
function handleSkip() {
goto('/onboarding/settings');
}
</script>
-<div class="space-y-6">
- <div class="text-center">
- <h2 class="text-2xl font-bold">Security Configuration</h2>
- <p class="text-muted-foreground mt-2">Configure authentication and security settings</p>
+<div class="space-y-8">
+ <div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
+ <div class="space-y-1">
+ <h2 class="text-2xl font-bold">Security Configuration</h2>
+ <p class="text-muted-foreground max-w-2xl text-sm">
+ Configure authentication methods, session policies, and security settings.
+ </p>
+ </div>
+ <div class="flex gap-2">
+ <Button variant="outline" onclick={handleBack}>Back</Button>
+ <Button variant="ghost" onclick={handleSkip}>Skip</Button>
+ <Button onclick={handleNext} disabled={isLoading.saving}>
+ {#if isLoading.saving}
+ <Loader2 class="mr-2 size-4 animate-spin" />
+ {/if}
+ Next
+ </Button>
+ </div>
</div>
<div class="grid gap-6 md:grid-cols-2">
- <Card.Root>
- <Card.Header>
- <Card.Title>Authentication</Card.Title>
- <Card.Description>Choose your authentication method</Card.Description>
- </Card.Header>
- <Card.Content class="space-y-4">
- <div class="space-y-2">
- <Label>Authentication Type</Label>
- <Select.Root type="single" bind:value={securitySettings.authType}>
- <Select.Trigger>
- {securitySettings.authType}
- </Select.Trigger>
- <Select.Content>
- <Select.Item value="local">Local Authentication</Select.Item>
- <Select.Item value="oidc">OIDC/OAuth2</Select.Item>
- </Select.Content>
- </Select.Root>
+ <!-- Authentication Methods (mirrors settings page) -->
+ <Card.Root class="border shadow-sm rounded-lg">
+ <Card.Header class="pb-2">
+ <div class="flex items-center gap-3">
+ <div class="rounded-md bg-indigo-500/10 p-2">
+ <Lock class="size-5 text-indigo-600" />
+ </div>
+ <div>
+ <Card.Title class="text-lg">Authentication Methods</Card.Title>
+ <Card.Description class="text-sm"
+ >Configure how users sign in to Arcane</Card.Description
+ >
+ </div>
</div>
+ </Card.Header>
+ <Card.Content class="pt-0">
+ <div class="space-y-4">
+ <div class="bg-muted/30 flex items-start justify-between rounded-lg border p-4">
+ <div class="space-y-1 pr-4">
+ <label for="localAuthSwitch" class="text-sm font-medium">Local Authentication</label>
+ <p class="text-muted-foreground text-xs">
+ Username and password stored in the system. Recommended as a fallback if OIDC is
+ unavailable.
+ </p>
+ </div>
+ <Switch
+ id="localAuthSwitch"
+ checked={localAuthEnabled}
+ onCheckedChange={(checked) => (localAuthEnabled = checked)}
+ />
+ </div>
- <div class="space-y-2">
- <Label for="session-timeout">Session Timeout (hours)</Label>
- <Select.Root type="single" bind:value={securitySettings.sessionTimeout}>
- <Select.Trigger>
- {securitySettings.sessionTimeout}
- </Select.Trigger>
- <Select.Content>
- <Select.Item value="1">1 hour</Select.Item>
- <Select.Item value="8">8 hours</Select.Item>
- <Select.Item value="24">24 hours</Select.Item>
- <Select.Item value="168">1 week</Select.Item>
- </Select.Content>
- </Select.Root>
+ <div class="bg-muted/30 flex items-start justify-between rounded-lg border p-4">
+ <div class="space-y-1 pr-4">
+ <label for="oidcAuthSwitch" class="text-sm font-medium">OIDC Authentication</label>
+ <p class="text-muted-foreground text-xs">
+ Use an external OIDC provider
+ {#if data.oidcStatus?.envForced}
+ <span class="text-muted-foreground text-[11px]"
+ >(Forced ON by server environment)</span
+ >
+ {/if}
+ </p>
+
+ {#if data.oidcStatus?.effectivelyEnabled || data.oidcStatus?.envForced}
+ <div class="mt-1">
+ {#if data.oidcStatus.envForced && !data.oidcStatus.envConfigured}
+ <Button
+ variant="link"
+ class="text-destructive h-auto p-0 text-xs hover:underline"
+ onclick={openOidcDialog}
+ >
+ <AlertTriangle class="mr-1 size-3" />
+ Server forces OIDC, but env vars are missing. Configure app settings or fix server
+ env.
+ </Button>
+ {:else if data.oidcStatus.envForced && data.oidcStatus.envConfigured}
+ <Button
+ variant="link"
+ class="h-auto p-0 text-xs text-sky-600 hover:underline"
+ onclick={openOidcDialog}
+ >
+ <Info class="mr-1 size-3" />
+ OIDC configured & forced by server. View Status.
+ </Button>
+ {:else if !data.oidcStatus.envForced && data.oidcStatus.effectivelyEnabled && data.oidcStatus.dbConfigured}
+ <Button
+ variant="link"
+ class="h-auto p-0 text-xs text-sky-600 hover:underline"
+ onclick={openOidcDialog}
+ >
+ <Info class="mr-1 size-3" />
+ OIDC configured via application settings. Manage.
+ </Button>
+ {:else if !data.oidcStatus.envForced && data.oidcStatus.effectivelyEnabled && !data.oidcStatus.dbConfigured}
+ <Button
+ variant="link"
+ class="text-destructive h-auto p-0 text-xs hover:underline"
+ onclick={openOidcDialog}
+ >
+ <AlertTriangle class="mr-1 size-3" />
+ OIDC enabled, but app settings incomplete. Configure.
+ </Button>
+ {/if}
+ </div>
+ {/if}
+ </div>
+
+ <Switch
+ id="oidcAuthSwitch"
+ checked={oidcEnabled}
+ disabled={data.oidcStatus?.envForced}
+ onCheckedChange={handleOidcSwitchChange}
+ />
+ </div>
</div>
</Card.Content>
</Card.Root>
- {#if securitySettings.authType === 'oidc'}
- <Card.Root>
- <Card.Header>
- <Card.Title>OIDC Configuration</Card.Title>
- <Card.Description>Configure your OIDC/OAuth2 provider</Card.Description>
- </Card.Header>
- <Card.Content class="space-y-4">
- <div class="space-y-2">
- <Label for="oidc-issuer-url">Issuer URL</Label>
- <Input
- id="oidc-issuer-url"
- bind:value={securitySettings.oidcIssuerUrl}
- placeholder="https://your-provider.com"
- />
- <p class="text-xs text-muted-foreground">
- The base URL of your OIDC provider (e.g., Keycloak, Auth0)
- </p>
- </div>
+ <OidcConfigDialog
+ bind:open={showOidcConfigDialog}
+ {currentSettings}
+ oidcStatus={data.oidcStatus}
+ bind:oidcForm={oidcConfigForm}
+ onSave={handleSaveOidcConfig}
+ />
- <div class="space-y-2">
- <Label for="oidc-client-id">Client ID</Label>
- <Input
- id="oidc-client-id"
- bind:value={securitySettings.oidcClientId}
- placeholder="your-client-id"
- />
+ <!-- Session Settings (mirrors settings page) -->
+ <Card.Root class="border shadow-sm rounded-lg">
+ <Card.Header class="pb-2">
+ <div class="flex items-center gap-3">
+ <div class="rounded-md bg-cyan-500/10 p-2">
+ <Key class="size-5 text-cyan-600" />
</div>
-
- <div class="space-y-2">
- <Label for="oidc-client-secret">Client Secret</Label>
- <Input
- id="oidc-client-secret"
- type="password"
- bind:value={securitySettings.oidcClientSecret}
- placeholder="your-client-secret"
- />
+ <div>
+ <Card.Title class="text-lg">Session Settings</Card.Title>
+ <Card.Description class="text-sm"
+ >Configure session behavior and password policies</Card.Description
+ >
</div>
-
+ </div>
+ </Card.Header>
+ <Card.Content class="pt-0">
+ <div class="space-y-5">
<div class="space-y-2">
- <Label for="oidc-scopes">Scopes</Label>
+ <Label for="sessionTimeout">Session Timeout (minutes)</Label>
<Input
- id="oidc-scopes"
- bind:value={securitySettings.oidcScopes}
- placeholder="openid email profile"
+ type="number"
+ id="sessionTimeout"
+ name="sessionTimeout"
+ bind:value={sessionTimeout}
+ min="15"
+ max="1440"
/>
- <p class="text-xs text-muted-foreground">Space-separated list of OAuth scopes</p>
+ <p class="text-muted-foreground text-xs">
+ Inactive sessions will be logged out automatically (15–1440 minutes).
+ </p>
</div>
- <div class="rounded-lg bg-muted/50 p-3">
- <p class="text-xs text-muted-foreground">
- <strong>Note:</strong> The redirect URI will be automatically set to:
- <code class="rounded bg-background px-1"
- >{window.location.origin}/auth/oidc/callback</code
+ <div class="space-y-2">
+ <Label for="passwordPolicy">Password Policy</Label>
+ <div class="grid grid-cols-3 gap-2">
+ <Button
+ variant={passwordPolicy === 'basic' ? 'default' : 'outline'}
+ class={passwordPolicy === 'basic'
+ ? 'arcane-button-create w-full'
+ : 'arcane-button-restart w-full'}
+ onclick={() => (passwordPolicy = 'basic')}
>
+ Basic
+ </Button>
+ <Button
+ variant={passwordPolicy === 'standard' ? 'default' : 'outline'}
+ class={passwordPolicy === 'standard'
+ ? 'arcane-button-create w-full'
+ : 'arcane-button-restart w-full'}
+ onclick={() => (passwordPolicy = 'standard')}
+ >
+ Standard
+ </Button>
+ <Button
+ variant={passwordPolicy === 'strong' ? 'default' : 'outline'}
+ class={passwordPolicy === 'strong'
+ ? 'arcane-button-create w-full'
+ : 'arcane-button-restart w-full'}
+ onclick={() => (passwordPolicy = 'strong')}
+ >
+ Strong
+ </Button>
+ </div>
+ <input type="hidden" id="passwordPolicy" name="passwordPolicy" value={passwordPolicy} />
+ <p class="text-muted-foreground mt-1 text-xs">
+ {#if passwordPolicy === 'basic'}
+ Basic: Minimum 8 characters
+ {:else if passwordPolicy === 'standard'}
+ Standard: Minimum 10 characters, requires mixed case and numbers
+ {:else}
+ Strong: Minimum 12 characters, requires mixed case, numbers and special characters
+ {/if}
</p>
</div>
- </Card.Content>
- </Card.Root>
- {:else}
- <Card.Root>
- <Card.Header>
- <Card.Title>Local Authentication</Card.Title>
- <Card.Description>Using local username/password authentication</Card.Description>
- </Card.Header>
- <Card.Content>
- <p class="text-sm text-muted-foreground">
- You're using local authentication with the admin password you set in the previous step.
- You can always switch to OIDC later in the settings.
- </p>
- </Card.Content>
- </Card.Root>
- {/if}
- </div>
-
- <div class="flex justify-between">
- <Button variant="outline" onclick={() => goto('/onboarding/docker')}>Back</Button>
- <div class="flex gap-2">
- <Button variant="ghost" onclick={handleSkip}>Skip</Button>
- <Button onclick={handleNext} disabled={isLoading}>
- {#if isLoading}
- <Loader2 class="mr-2 size-4 animate-spin" />
- {/if}
- Next
- </Button>
- </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
</div>
</div>
diff --git a/frontend/src/routes/onboarding/security/+page.ts b/frontend/src/routes/onboarding/security/+page.ts
index 476d17ce0..3748b84e2 100644
--- a/frontend/src/routes/onboarding/security/+page.ts
+++ b/frontend/src/routes/onboarding/security/+page.ts
@@ -3,11 +3,21 @@ import type { PageLoad } from './$types';
import { settingsAPI } from '$lib/services/api';
export const load: PageLoad = async () => {
- const settings = await settingsAPI.getSettings();
+ const [settings, oidcStatus] = await Promise.all([
+ settingsAPI.getSettings(),
+ settingsAPI.getOidcStatus().catch(() => ({
+ envForced: false,
+ envConfigured: false,
+ dbEnabled: false,
+ dbConfigured: false,
+ effectivelyEnabled: false,
+ effectivelyConfigured: false
+ }))
+ ]);
if (settings.onboardingCompleted) {
throw redirect(302, '/dashboard');
}
- return { settings };
+ return { settings, oidcStatus };
};