Fix migrate lock scope and stop RealIP from bypassing proxy trust.

Hold a session advisory lock for the full migration apply path, and remove Chi RealIP so clientIP can validate the TCP peer before walking X-Forwarded-For.
This commit is contained in:
2026-08-22 12:25:16 -07:00
parent 29b0536215
commit 35c8c9f391
4 changed files with 89 additions and 24 deletions
+3 -3
View File
@@ -148,9 +148,9 @@ func New(st store.Store, sessionStore scs.Store, templateFS fs.FS, staticFS fs.F
func (s *Server) Handler() http.Handler {
r := chi.NewRouter()
r.Use(middleware.RequestID)
if len(s.cfg.TrustedProxies) > 0 {
r.Use(middleware.RealIP)
}
// Do not use middleware.RealIP: it rewrites RemoteAddr from client-controlled
// forwarding headers before clientIP can validate the TCP peer against
// TrustedProxies. clientIP walks X-Forwarded-For itself when the peer is trusted.
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
r.Use(func(next http.Handler) http.Handler {