mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-10-28 15:02:28 +00:00
monitoring: Use method-based routing and CSRF for http requests
The monitoring http server is mostly read-only but shows sensitive data, and also has one mutating endpoint, /exit. This patch updates the routing to use method-based routing, and also wraps it on CSRF to reject cross-origin requests from browsers. Note that does not affect direct POST /exit requests via tools like curl or wget, which continue to work just like today. This is exercised in the (unchanged) integration tests.
This commit is contained in:
@@ -237,7 +237,7 @@ func (s *Server) InitQueue(path string, localC, remoteC courier.Courier) {
|
||||
}
|
||||
s.queue = q
|
||||
|
||||
http.HandleFunc("/debug/queue",
|
||||
http.HandleFunc("GET /debug/queue",
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(q.DumpString()))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user