feat: add auth middleware for protected routes

Add RequireAuth middleware that checks for a valid session and
redirects unauthenticated users to /pages/login. Applied to all
/sources and /source/{sourceID} routes. The middleware uses the
existing session package for authentication checks.

closes #9
This commit is contained in:
clawbot
2026-03-01 15:55:51 -08:00
committed by user
parent e6b79ce1be
commit 7d13c9da17
2 changed files with 27 additions and 7 deletions

View File

@@ -92,14 +92,14 @@ func (s *Server) SetupRoutes() {
// Webhook management routes (require authentication)
s.router.Route("/sources", func(r chi.Router) {
// TODO: Add authentication middleware here
r.Use(s.mw.RequireAuth())
r.Get("/", s.h.HandleSourceList()) // List all webhooks
r.Get("/new", s.h.HandleSourceCreate()) // Show create form
r.Post("/new", s.h.HandleSourceCreateSubmit()) // Handle create submission
})
s.router.Route("/source/{sourceID}", func(r chi.Router) {
// TODO: Add authentication middleware here
r.Use(s.mw.RequireAuth())
r.Get("/", s.h.HandleSourceDetail()) // View webhook details
r.Get("/edit", s.h.HandleSourceEdit()) // Show edit form
r.Post("/edit", s.h.HandleSourceEditSubmit()) // Handle edit submission