Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix: OIDC login now uses server-side redirect for same-window navigation
rcourtman491f6d13c714
diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsxindex 2471838076..3692766c9c 100644--- a/frontend-modern/src/components/Login.tsx+++ b/frontend-modern/src/components/Login.tsx@@ -125,7 +125,7 @@ export const Login: Component<LoginProps> = (props) => {}});- const startOidcLogin = async () => {+ const startOidcLogin = () => {if (!supportsOIDC()) return;setOidcError('');@@ -133,30 +133,11 @@ export const Login: Component<LoginProps> = (props) => {setError('');setOidcLoading(true);- let redirecting = false;- try {- const data = await apiFetchJSON<{ authorizationUrl: string }>('/api/oidc/login', {- method: 'POST',- body: JSON.stringify({- returnTo: `${window.location.pathname}${window.location.search}`,- }),- });-- if (data.authorizationUrl) {- redirecting = true;- window.location.href = data.authorizationUrl;- return;- }-- throw new Error('OIDC response missing authorization URL');- } catch (err) {- logger.error('[Login] Failed to start OIDC login:', err);- setOidcError('Failed to start single sign-on. Please try again.');- } finally {- if (!redirecting) {- setOidcLoading(false);- }- }+ // Navigate directly to the OIDC login endpoint using GET.+ // The server will respond with an HTTP redirect to the OIDC provider.+ // This guarantees same-window navigation in all browsers, including Arc.+ const returnTo = encodeURIComponent(`${window.location.pathname}${window.location.search}`);+ window.location.href = `/api/oidc/login?returnTo=${returnTo}`;};// Auto-redirect to OIDC is intentionally disabled to prevent redirect loopsdiff --git a/internal/api/oidc_handlers.go b/internal/api/oidc_handlers.goindex 754abcf907..f1f1277c6b 100644--- a/internal/api/oidc_handlers.go+++ b/internal/api/oidc_handlers.go@@ -16,13 +16,19 @@ import ()func (r *Router) handleOIDCLogin(w http.ResponseWriter, req *http.Request) {- if req.Method != http.MethodPost {- writeErrorResponse(w, http.StatusMethodNotAllowed, "method_not_allowed", "Only POST is allowed", nil)+ // Support both GET (direct redirect) and POST (JSON response)+ // GET is preferred for browsers as it guarantees same-window navigation+ if req.Method != http.MethodGet && req.Method != http.MethodPost {+ writeErrorResponse(w, http.StatusMethodNotAllowed, "method_not_allowed", "Only GET or POST is allowed", nil)return}cfg := r.ensureOIDCConfig()if cfg == nil || !cfg.Enabled {+ if req.Method == http.MethodGet {+ http.Error(w, "OIDC authentication is not enabled", http.StatusBadRequest)+ return+ }writeErrorResponse(w, http.StatusBadRequest, "oidc_disabled", "OIDC authentication is not enabled", nil)return}@@ -33,31 +39,51 @@ func (r *Router) handleOIDCLogin(w http.ResponseWriter, req *http.Request) {service, err := r.getOIDCService(req.Context(), redirectURL)if err != nil {log.Error().Err(err).Str("issuer", cfg.IssuerURL).Msg("Failed to initialise OIDC service")+ if req.Method == http.MethodGet {+ http.Error(w, "OIDC provider is unavailable", http.StatusInternalServerError)+ return+ }writeErrorResponse(w, http.StatusInternalServerError, "oidc_init_failed", "OIDC provider is unavailable", nil)return}log.Debug().Str("issuer", cfg.IssuerURL).Str("client_id", cfg.ClientID).Msg("Starting OIDC login flow")- var payload struct {- ReturnTo string `json:"returnTo"`- }- if err := json.NewDecoder(req.Body).Decode(&payload); err != nil && err != io.EOF {- writeErrorResponse(w, http.StatusBadRequest, "invalid_request", "Invalid request payload", nil)- return+ var returnTo string+ if req.Method == http.MethodPost {+ var payload struct {+ ReturnTo string `json:"returnTo"`+ }+ if err := json.NewDecoder(req.Body).Decode(&payload); err != nil && err != io.EOF {+ writeErrorResponse(w, http.StatusBadRequest, "invalid_request", "Invalid request payload", nil)+ return+ }+ returnTo = sanitizeOIDCReturnTo(payload.ReturnTo)+ } else {+ // GET: read returnTo from query param+ returnTo = sanitizeOIDCReturnTo(req.URL.Query().Get("returnTo"))}- returnTo := sanitizeOIDCReturnTo(payload.ReturnTo)-state, entry, err := service.newStateEntry(returnTo)if err != nil {log.Error().Err(err).Msg("Failed to create OIDC state entry")+ if req.Method == http.MethodGet {+ http.Error(w, "Unable to start OIDC login", http.StatusInternalServerError)+ return+ }writeErrorResponse(w, http.StatusInternalServerError, "oidc_state_error", "Unable to start OIDC login", nil)return}authURL := service.authCodeURL(state, entry)+ // GET: direct HTTP redirect (guarantees same-window navigation in all browsers)+ // POST: return JSON (for API clients/backwards compatibility)+ if req.Method == http.MethodGet {+ http.Redirect(w, req, authURL, http.StatusFound)+ return+ }+w.Header().Set("Content-Type", "application/json")json.NewEncoder(w).Encode(map[string]interface{}{"authorizationUrl": authURL,