From d5404127d66d0821ca938f4221429bd1677e798f Mon Sep 17 00:00:00 2001 From: wucm667 Date: Fri, 1 May 2026 09:18:13 +0800 Subject: [PATCH 1/3] fix(oidc): report provider initialization status to prevent auto-redirect failure When the OIDC issuer (e.g. Authentik) is not reachable at startup, the provider initialization fails silently and ctrl.oidcProvider remains nil. However, the status endpoint still reports oidc.enabled=true, causing the frontend to auto-redirect to a broken /api/v1/users/login/oidc endpoint which returns HTTP 500 "OIDC provider not available". Add an "initialized" field to OIDCStatus that reflects whether the provider was actually created successfully. The frontend now checks this field before auto-redirecting or showing the OIDC login button. Fixes sysadminsmedia/homebox#1471 Signed-off-by: wucm667 --- backend/app/api/handlers/v1/controller.go | 2 ++ frontend/lib/api/types/data-contracts.ts | 1 + frontend/pages/index.vue | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.go index f9c5d3af3..f7e18ce4b 100644 --- a/backend/app/api/handlers/v1/controller.go +++ b/backend/app/api/handlers/v1/controller.go @@ -106,6 +106,7 @@ type ( ButtonText string `json:"buttonText,omitempty"` AutoRedirect bool `json:"autoRedirect,omitempty"` AllowLocal bool `json:"allowLocal"` + Initialized bool `json:"initialized"` } TelemetryStatus struct { @@ -166,6 +167,7 @@ func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) errchain.Hand ButtonText: ctrl.config.OIDC.ButtonText, AutoRedirect: ctrl.config.OIDC.AutoRedirect, AllowLocal: ctrl.config.Options.AllowLocalLogin, + Initialized: ctrl.oidcProvider != nil, }, Telemetry: TelemetryStatus{ Enabled: ctrl.config.Otel.Enabled, diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index 1a869f988..35605dcc2 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -1218,6 +1218,7 @@ export interface OIDCStatus { autoRedirect: boolean; buttonText: string; enabled: boolean; + initialized: boolean; } export interface TelemetryStatus { diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index 2044badfb..9303520e7 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -73,7 +73,13 @@ } // Auto-redirect to OIDC if autoRedirect is enabled, but not if there's an OIDC initialization error - if (status?.oidc?.enabled && status?.oidc?.autoRedirect && !oidcError.value && !shownErrorMessage.value) { + if ( + status?.oidc?.enabled && + status?.oidc?.initialized && + status?.oidc?.autoRedirect && + !oidcError.value && + !shownErrorMessage.value + ) { loginWithOIDC(); } }); @@ -384,7 +390,7 @@