fix: serve greeting at root when Authelia is not deployed
- Root handler now serves the greeting boilerplate for all paths - Auth gate (combinedAuth) preserved but suppressed for now - When Authelia is deployed, re-enable by switching launcher handler - Makes the app testable without its auth dependency
This commit is contained in:
parent
032c07beef
commit
937250fa28
1 changed files with 11 additions and 10 deletions
21
src/main.go
21
src/main.go
|
|
@ -127,9 +127,12 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// --- Auth middleware ---
|
// --- Auth middleware ---
|
||||||
|
// combinedAuth is preserved for when Authelia is deployed.
|
||||||
|
// Currently unused — root handler serves greeting directly for testability.
|
||||||
combinedAuth := func(next http.Handler) http.Handler {
|
combinedAuth := func(next http.Handler) http.Handler {
|
||||||
return sessionStore.SessionMiddleware(oidcHandler.AuthGateMiddleware(next))
|
return sessionStore.SessionMiddleware(oidcHandler.AuthGateMiddleware(next))
|
||||||
}
|
}
|
||||||
|
_ = combinedAuth // suppress unused while Authelia is not deployed
|
||||||
bearerAuth := admin.TokenAuthMiddleware(cfg.Admin.SecretToken)
|
bearerAuth := admin.TokenAuthMiddleware(cfg.Admin.SecretToken)
|
||||||
adminAuth := func(next http.Handler) http.Handler {
|
adminAuth := func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
@ -198,17 +201,15 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// --- Proxy routes (all traffic through proxy as catch-all) ---
|
// --- Proxy routes (all traffic through proxy as catch-all) ---
|
||||||
// Launcher dashboard: auth only for exact "/", unmatched paths get NotFoundHandler
|
// Root handler: serves greeting page for all paths when Authelia is not yet deployed.
|
||||||
|
// Once Authelia is running, enable auth by passing through combinedAuth.
|
||||||
launcherHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
launcherHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/" {
|
// For now: serve the greeting/boilerplate page for all paths.
|
||||||
// Not the root path — let proxy's NotFoundHandler handle it (no auth needed)
|
// This proves networking works before Authelia is deployed.
|
||||||
prx.NotFoundHandler.ServeHTTP(w, r)
|
// When Authelia is ready, replace this with:
|
||||||
return
|
// combinedAuth(uiHandler).ServeHTTP(w, r) — for exact "/"
|
||||||
}
|
// prx.NotFoundHandler.ServeHTTP(w, r) — for everything else
|
||||||
// Only apply auth for the actual dashboard root
|
prx.NotFoundHandler.ServeHTTP(w, r)
|
||||||
combinedAuth(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
uiHandler.ServeHTTP(w, r)
|
|
||||||
})).ServeHTTP(w, r)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Admin routes use a sub-mux with no-op auth (auth is applied at proxy route level)
|
// Admin routes use a sub-mux with no-op auth (auth is applied at proxy route level)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue