diff --git a/internal/web/handlers.go b/internal/web/handlers.go index bd81d03..2e06cb5 100644 --- a/internal/web/handlers.go +++ b/internal/web/handlers.go @@ -229,7 +229,12 @@ func (a *App) Router() http.Handler { // resolved user_id. /register lives inside the auth guard but is exempt from // the registration gate (you must be able to reach it before you have a user). root.Handle("/", a.Auth.Middleware(a.registrationGate(app))) - return root + + // The session cookie is SameSite=Lax, which still travels on a POST made from a + // sibling *.d-ma.be page (same site, different origin). Refuse any non-safe request + // whose Origin or Sec-Fetch-Site says it did not come from this origin (#48). It wraps + // everything, so a route added later is covered without remembering to ask. + return http.NewCrossOriginProtection().Handler(root) } // handleWelcome renders the public landing page (/welcome). It is mounted outside