fix(auth): chain session middleware before auth gate to prevent redirect loop

This commit is contained in:
Claus Lohmar 2026-06-14 14:52:25 +00:00
parent 3ccaada226
commit c89f823cb6

View file

@ -116,10 +116,11 @@ func main() {
}) })
// --- Workspace launcher (public, but OIDC-protected) --- // --- Workspace launcher (public, but OIDC-protected) ---
sessionMiddleware := sessionStore.SessionMiddleware // Chain: SessionMiddleware (reads cookie → sets context) → AuthGate (checks context → redirects if needed)
authGate := oidcHandler.AuthGateMiddleware combinedAuth := func(next http.Handler) http.Handler {
uiHandler.RegisterRoutes(mux, authGate) return sessionStore.SessionMiddleware(oidcHandler.AuthGateMiddleware(next))
_ = sessionMiddleware // Used for session-aware middleware in future }
uiHandler.RegisterRoutes(mux, combinedAuth)
// --- Admin routes (protected by bearer token) --- // --- Admin routes (protected by bearer token) ---
adminAuth := admin.TokenAuthMiddleware(cfg.Admin.SecretToken) adminAuth := admin.TokenAuthMiddleware(cfg.Admin.SecretToken)