Skip to content

Modern Docker Management, Designed for Everyone

refactor: refactor oidc status config

Kyle Mendell3c2d54d78c60
diff --git a/.github/workflows/svelte-check.yml b/.github/workflows/svelte-check.yml
index fe38e7060..a82ecaced 100644
--- a/.github/workflows/svelte-check.yml
+++ b/.github/workflows/svelte-check.yml
@@ -49,7 +49,8 @@ jobs:
- name: Install dependencies
run: pnpm --filter arcane-frontend install --frozen-lockfile
- - name: Run Svelte Check
- uses: ofkm/gha-svelte-check@v1
- with:
- working-directory: './frontend'
+ - name: Add svelte-check problem matcher
+ run: echo "::add-matcher::.github/svelte-check-matcher.json"
+
+ - name: Run svelte-check
+ run: pnpm --filter arcane-frontend check
diff --git a/backend/internal/dto/oidc.go b/backend/internal/dto/oidc.go
index 2b9c78b4c..ffc46e741 100644
--- a/backend/internal/dto/oidc.go
+++ b/backend/internal/dto/oidc.go
@@ -35,10 +35,6 @@ type OidcTokenResponse struct {
}
type OidcStatusInfo struct {
- EnvForced bool `json:"envForced"`
- EnvConfigured bool `json:"envConfigured"`
- DbEnabled bool `json:"dbEnabled"`
- DbConfigured bool `json:"dbConfigured"`
- EffectivelyEnabled bool `json:"effectivelyEnabled"`
- EffectivelyConfigured bool `json:"effectivelyConfigured"`
+ EnvForced bool `json:"envForced"`
+ EnvConfigured bool `json:"envConfigured"`
}
diff --git a/backend/internal/services/auth_service.go b/backend/internal/services/auth_service.go
index 86fbd7eb4..e0ca80dbf 100644
--- a/backend/internal/services/auth_service.go
+++ b/backend/internal/services/auth_service.go
@@ -39,15 +39,6 @@ type AuthSettings struct {
Oidc *models.OidcConfig `json:"oidc,omitempty"`
}
-type OidcStatusInfo struct {
- EnvForced bool `json:"envForced"`
- EnvConfigured bool `json:"envConfigured"`
- DbEnabled bool `json:"dbEnabled"`
- DbConfigured bool `json:"dbConfigured"`
- EffectivelyEnabled bool `json:"effectivelyEnabled"`
- EffectivelyConfigured bool `json:"effectivelyConfigured"`
-}
-
type UserClaims struct {
jwt.RegisteredClaims
UserID string `json:"user_id"`
@@ -62,7 +53,6 @@ type AuthService struct {
settingsService *SettingsService
eventService *EventService
jwtSecret []byte
- accessExpiry time.Duration
refreshExpiry time.Duration
config *config.Config
}
@@ -73,7 +63,6 @@ func NewAuthService(userService *UserService, settingsService *SettingsService,
settingsService: settingsService,
eventService: eventService,
jwtSecret: utils.CheckOrGenerateJwtSecret(jwtSecret),
- accessExpiry: 30 * time.Minute,
refreshExpiry: 7 * 24 * time.Hour,
config: cfg,
}
@@ -104,31 +93,12 @@ func (s *AuthService) getAuthSettings(ctx context.Context) (*AuthSettings, error
}
func (s *AuthService) GetOidcConfigurationStatus(ctx context.Context) (*dto.OidcStatusInfo, error) {
- status := &dto.OidcStatusInfo{}
-
- status.EnvForced = s.config.OidcEnabled
-
+ status := &dto.OidcStatusInfo{
+ EnvForced: s.config.OidcEnabled,
+ }
if s.config.OidcEnabled {
status.EnvConfigured = s.config.OidcClientID != "" && s.config.OidcIssuerURL != ""
}
-
- effectiveAuthSettings, err := s.getAuthSettings(ctx)
- if err != nil {
- return status, fmt.Errorf("failed to get effective auth settings for OIDC status: %w", err)
- }
-
- status.DbEnabled = effectiveAuthSettings.OidcEnabled
- if effectiveAuthSettings.Oidc != nil {
- status.DbConfigured = effectiveAuthSettings.Oidc.ClientID != "" &&
- (effectiveAuthSettings.Oidc.IssuerURL != "" ||
- (effectiveAuthSettings.Oidc.AuthorizationEndpoint != "" &&
- effectiveAuthSettings.Oidc.TokenEndpoint != "" &&
- effectiveAuthSettings.Oidc.UserinfoEndpoint != ""))
- }
-
- status.EffectivelyEnabled = status.DbEnabled
- status.EffectivelyConfigured = status.DbConfigured
-
return status, nil
}
diff --git a/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte b/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte
index 7f2e42c13..a4cbe3c65 100644
--- a/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte
+++ b/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte
@@ -9,7 +9,7 @@
import { Label } from '$lib/components/ui/label/index.js';
import { toast } from 'svelte-sonner';
import type { Settings } from '$lib/types/settings.type';
- import type { OidcStatus } from '$lib/services/api/oidc-api-service';
+ import type { OidcStatusInfo } from '$lib/types/settings.type';
interface OidcForm {
clientId: string;
@@ -29,7 +29,7 @@
}: {
open: boolean;
currentSettings: Settings;
- oidcStatus: OidcStatus;
+ oidcStatus: OidcStatusInfo;
oidcForm: OidcForm;
onSave: () => void;
} = $props();
@@ -66,9 +66,7 @@
const statusItems = $derived([
{ label: 'Env Forced', value: oidcStatus.envForced, hint: 'Server forces OIDC' },
- { label: 'Env Configured', value: oidcStatus.envConfigured, hint: 'Server OIDC vars present' },
- { label: 'DB Enabled', value: oidcStatus.dbEnabled, hint: 'App settings enable OIDC' },
- { label: 'DB Configured', value: oidcStatus.dbConfigured, hint: 'App OIDC config saved' }
+ { label: 'Env Configured', value: oidcStatus.envConfigured, hint: 'Server OIDC vars present' }
]);
function chipClass(v: boolean) {
diff --git a/frontend/src/lib/components/ui/button/button.svelte b/frontend/src/lib/components/ui/button/button.svelte
index 16f1a3ccb..638b27f4f 100644
--- a/frontend/src/lib/components/ui/button/button.svelte
+++ b/frontend/src/lib/components/ui/button/button.svelte
@@ -1,5 +1,6 @@
<script lang="ts" module>
import { cn, type WithElementRef } from '$lib/utils.js';
+ import type { WithChildren } from 'bits-ui';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
import { type VariantProps, tv } from 'tailwind-variants';
@@ -32,6 +33,18 @@
export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
+ export type ButtonPropsWithoutHTML = WithChildren<{
+ ref?: HTMLElement | null;
+ variant?: ButtonVariant;
+ size?: ButtonSize;
+ loading?: boolean;
+ onClickPromise?: (
+ e: MouseEvent & {
+ currentTarget: EventTarget & HTMLButtonElement;
+ }
+ ) => Promise<void>;
+ }>;
+
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
WithElementRef<HTMLAnchorAttributes> & {
variant?: ButtonVariant;
diff --git a/frontend/src/lib/components/ui/button/index.ts b/frontend/src/lib/components/ui/button/index.ts
index 3fd7e24ba..7e0e69496 100644
--- a/frontend/src/lib/components/ui/button/index.ts
+++ b/frontend/src/lib/components/ui/button/index.ts
@@ -1,4 +1,10 @@
-import Root, { type ButtonProps, type ButtonSize, type ButtonVariant, buttonVariants } from './button.svelte';
+import Root, {
+ type ButtonProps,
+ type ButtonPropsWithoutHTML,
+ type ButtonSize,
+ type ButtonVariant,
+ buttonVariants
+} from './button.svelte';
export {
Root,
@@ -8,5 +14,6 @@ export {
buttonVariants,
type ButtonProps,
type ButtonSize,
- type ButtonVariant
+ type ButtonVariant,
+ type ButtonPropsWithoutHTML
};
diff --git a/frontend/src/lib/components/ui/copy-button/copy-button.svelte b/frontend/src/lib/components/ui/copy-button/copy-button.svelte
index a0cd7fb08..9fae4d1e9 100644
--- a/frontend/src/lib/components/ui/copy-button/copy-button.svelte
+++ b/frontend/src/lib/components/ui/copy-button/copy-button.svelte
@@ -22,8 +22,7 @@
onCopy,
class: className,
tabindex = -1,
- children,
- ...rest
+ children
}: CopyButtonProps = $props();
// this way if the user passes text then the button will be the default size
@@ -35,7 +34,6 @@
</script>
<Button
- {...rest}
bind:ref
{variant}
{size}
diff --git a/frontend/src/lib/components/ui/snippet/snippet.svelte b/frontend/src/lib/components/ui/snippet/snippet.svelte
index 018c66a7a..050bf00c1 100644
--- a/frontend/src/lib/components/ui/snippet/snippet.svelte
+++ b/frontend/src/lib/components/ui/snippet/snippet.svelte
@@ -36,19 +36,21 @@
<div class={cn(style({ variant, className: className }))}>
{#if typeof text == 'string'}
- <pre class={cn('overflow-y-auto text-left font-mono text-sm font-light whitespace-nowrap')}>
+ <pre class={cn('overflow-y-auto whitespace-nowrap text-left font-mono text-sm font-light')}>
{text}
</pre>
{:else}
{#each text as line, i (i)}
- <pre class={cn('overflow-y-auto text-left font-mono text-sm font-light whitespace-nowrap')}>
+ <pre class={cn('overflow-y-auto whitespace-nowrap text-left font-mono text-sm font-light')}>
{line}
</pre>
{/each}
{/if}
<CopyButton
- class="hover:text-opacity-80 absolute top-1/2 right-2 size-7 -translate-y-1/2 transition-opacity ease-in-out hover:bg-transparent dark:hover:bg-transparent"
+ size="icon"
+ variant="ghost"
+ class="absolute right-2 top-1/2 size-7 -translate-y-1/2 transition-opacity ease-in-out hover:bg-transparent hover:text-opacity-80 dark:hover:bg-transparent"
text={typeof text === 'string' ? text : text.join('\n')}
{onCopy}
/>
diff --git a/frontend/src/lib/services/api/oidc-api-service.ts b/frontend/src/lib/services/api/oidc-api-service.ts
index f014126cb..836072e43 100644
--- a/frontend/src/lib/services/api/oidc-api-service.ts
+++ b/frontend/src/lib/services/api/oidc-api-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import type { OidcConfig } from '$lib/types/settings.type';
+import type { OidcConfig, OidcStatusInfo } from '$lib/types/settings.type';
export interface OidcUserInfo {
sub: string;
@@ -13,12 +13,10 @@ export interface OidcUserInfo {
groups?: string[];
}
-export interface OidcStatus {
- envForced: boolean;
- envConfigured: boolean;
- dbEnabled: boolean;
- dbConfigured: boolean;
-}
+// export interface OidcStatus {
+// envForced: boolean;
+// envConfigured: boolean;
+// }
export default class OidcAPIService extends BaseAPIService {
async getAuthUrl(redirectUri: string): Promise<string> {
@@ -40,7 +38,7 @@ export default class OidcAPIService extends BaseAPIService {
return this.handleResponse(this.api.post('/oidc/callback', { code, state }));
}
- async getStatus(): Promise<OidcStatus> {
+ async getStatus(): Promise<OidcStatusInfo> {
return this.handleResponse(this.api.get('/oidc/status'));
}
diff --git a/frontend/src/lib/types/settings.type.ts b/frontend/src/lib/types/settings.type.ts
index 088e45141..4a602fd5e 100644
--- a/frontend/src/lib/types/settings.type.ts
+++ b/frontend/src/lib/types/settings.type.ts
@@ -76,8 +76,4 @@ export interface OidcConfig {
export interface OidcStatusInfo {
envForced: boolean;
envConfigured: boolean;
- dbEnabled: boolean;
- dbConfigured: boolean;
- effectivelyEnabled: boolean;
- effectivelyConfigured: boolean;
}
diff --git a/frontend/src/routes/auth/oidc/login/+page.svelte b/frontend/src/routes/auth/oidc/login/+page.svelte
index 709573340..d384bdc4f 100644
--- a/frontend/src/routes/auth/oidc/login/+page.svelte
+++ b/frontend/src/routes/auth/oidc/login/+page.svelte
@@ -12,12 +12,6 @@
const redirect = page.url.searchParams.get('redirect') || '/dashboard';
const status = await oidcAPI.getStatus();
- if (!status.dbEnabled || !status.dbConfigured) {
- error = 'OIDC authentication is not properly configured. Please contact your administrator.';
- setTimeout(() => goto('/auth/login?error=oidc_not_configured'), 3000);
- isRedirecting = false;
- return;
- }
const authUrl = await oidcAPI.getAuthUrl(redirect);
if (!authUrl) {
diff --git a/frontend/src/routes/onboarding/security/+page.svelte b/frontend/src/routes/onboarding/security/+page.svelte
index 178207956..6852cf8cf 100644
--- a/frontend/src/routes/onboarding/security/+page.svelte
+++ b/frontend/src/routes/onboarding/security/+page.svelte
@@ -79,7 +79,8 @@
function handleOidcSwitchChange(checked: boolean) {
oidcEnabled = checked;
- if (checked && !data.oidcStatus?.envForced && !data.oidcStatus?.effectivelyConfigured) {
+ // If enabling and not forced by env, open the config dialog
+ if (checked && !data.oidcStatus?.envForced) {
showOidcConfigDialog = true;
}
}
@@ -239,27 +240,17 @@
{/if}
</p>
- {#if data.oidcStatus?.effectivelyEnabled || data.oidcStatus?.envForced}
+ {#if data.oidcStatus?.envForced}
<div class="mt-1">
- {#if data.oidcStatus.envForced && !data.oidcStatus.envConfigured}
+ {#if !data.oidcStatus.envConfigured}
<Button variant="link" class="text-destructive h-auto p-0 text-xs hover:underline" onclick={openOidcDialog}>
<TriangleAlertIcon 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}
+ {:else}
<Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
<InfoIcon 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}>
- <InfoIcon 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}>
- <TriangleAlertIcon class="mr-1 size-3" />
- OIDC enabled, but app settings incomplete. Configure.
+ OIDC configured & forced by server. View status.
</Button>
{/if}
</div>
diff --git a/frontend/src/routes/onboarding/security/+page.ts b/frontend/src/routes/onboarding/security/+page.ts
index 3748b84e2..a3a701249 100644
--- a/frontend/src/routes/onboarding/security/+page.ts
+++ b/frontend/src/routes/onboarding/security/+page.ts
@@ -7,11 +7,7 @@ export const load: PageLoad = async () => {
settingsAPI.getSettings(),
settingsAPI.getOidcStatus().catch(() => ({
envForced: false,
- envConfigured: false,
- dbEnabled: false,
- dbConfigured: false,
- effectivelyEnabled: false,
- effectivelyConfigured: false
+ envConfigured: false
}))
]);
diff --git a/frontend/src/routes/settings/forms/security-settings-form.svelte b/frontend/src/routes/settings/forms/security-settings-form.svelte
index d6b714bdc..afbf4740a 100644
--- a/frontend/src/routes/settings/forms/security-settings-form.svelte
+++ b/frontend/src/routes/settings/forms/security-settings-form.svelte
@@ -8,7 +8,7 @@
import OidcConfigDialog from '$lib/components/dialogs/oidc-config-dialog.svelte';
import { toast } from 'svelte-sonner';
import type { Settings } from '$lib/types/settings.type';
- import type { OidcStatus } from '$lib/services/api/oidc-api-service';
+ import type { OidcStatusInfo } from '$lib/types/settings.type';
import * as Tooltip from '$lib/components/ui/tooltip/index.js';
let {
@@ -17,7 +17,7 @@
callback
}: {
settings: Settings;
- oidcStatus: OidcStatus;
+ oidcStatus: OidcStatusInfo;
callback: (appConfig: Partial<Settings>) => Promise<void>;
} = $props();
@@ -88,8 +88,8 @@
.then(() => toast.success('Settings Saved Successfully'))
.finally(() => (isLoading.saving = false));
}
- const effectivelyEnabled = $derived(oidcStatus.envForced || oidcStatus.dbEnabled);
+ // Only depend on envForced; open config when enabling and not forced
function handleOidcSwitchChange(checked: boolean) {
$formInputs.authOidcEnabled.value = checked;
@@ -98,7 +98,7 @@
toast.info('Local Authentication enabled to ensure at least one provider is active.');
}
- if (checked && !oidcStatus.envForced && !effectivelyEnabled) {
+ if (checked && !oidcStatus.envForced) {
showOidcConfigDialog = true;
}
}
@@ -182,23 +182,22 @@
checked={$formInputs.authOidcEnabled.value}
onCheckedChange={handleOidcSwitchChange}
/>
- {#if effectivelyEnabled}
+
+ {#if isOidcActive()}
<div class="pl-11">
- {#if oidcStatus.envForced && !oidcStatus.envConfigured}
- <Button variant="link" class="text-destructive h-auto p-0 text-xs hover:underline" onclick={openOidcDialog}>
- Server forces OIDC, but env vars missing. Configure or fix server env.
- </Button>
- {:else if oidcStatus.envForced && oidcStatus.envConfigured}
+ {#if oidcStatus.envForced}
+ {#if !oidcStatus.envConfigured}
+ <Button variant="link" class="text-destructive h-auto p-0 text-xs hover:underline" onclick={openOidcDialog}>
+ Server forces OIDC, but env vars missing. Configure or fix server env.
+ </Button>
+ {:else}
+ <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
+ OIDC configured & forced by server. View status.
+ </Button>
+ {/if}
+ {:else}
<Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
- OIDC configured & forced by server. View status.
- </Button>
- {:else if !oidcStatus.envForced && effectivelyEnabled && oidcStatus.dbConfigured}
- <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
- OIDC configured via application settings. Manage.
- </Button>
- {:else if !oidcStatus.envForced && effectivelyEnabled && !oidcStatus.dbConfigured}
- <Button variant="link" class="text-destructive h-auto p-0 text-xs hover:underline" onclick={openOidcDialog}>
- OIDC enabled, but settings incomplete. Configure.
+ Manage OIDC configuration
</Button>
{/if}
</div>
diff --git a/frontend/src/routes/settings/security/+page.ts b/frontend/src/routes/settings/security/+page.ts
index 24d37bd0a..f00fa13b8 100644
--- a/frontend/src/routes/settings/security/+page.ts
+++ b/frontend/src/routes/settings/security/+page.ts
@@ -5,11 +5,7 @@ export const load = async () => {
settingsAPI.getSettings(),
settingsAPI.getOidcStatus().catch(() => ({
envForced: false,
- envConfigured: false,
- dbEnabled: false,
- dbConfigured: false,
- effectivelyEnabled: false,
- effectivelyConfigured: false
+ envConfigured: false
}))
]);