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) ---
sessionMiddleware := sessionStore.SessionMiddleware
authGate := oidcHandler.AuthGateMiddleware
uiHandler.RegisterRoutes(mux, authGate)
_ = sessionMiddleware // Used for session-aware middleware in future
// Chain: SessionMiddleware (reads cookie → sets context) → AuthGate (checks context → redirects if needed)
combinedAuth := func(next http.Handler) http.Handler {
return sessionStore.SessionMiddleware(oidcHandler.AuthGateMiddleware(next))
}
uiHandler.RegisterRoutes(mux, combinedAuth)
// --- Admin routes (protected by bearer token) ---
adminAuth := admin.TokenAuthMiddleware(cfg.Admin.SecretToken)