fix(web): refuse cross-origin non-safe requests at the router (#48)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,12 @@ func (a *App) Router() http.Handler {
|
|||||||
// resolved user_id. /register lives inside the auth guard but is exempt from
|
// 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).
|
// the registration gate (you must be able to reach it before you have a user).
|
||||||
root.Handle("/", a.Auth.Middleware(a.registrationGate(app)))
|
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
|
// handleWelcome renders the public landing page (/welcome). It is mounted outside
|
||||||
|
|||||||
Reference in New Issue
Block a user