Add trusted proxy middleware and simplify clientip

Strip forwarded headers (Forwarded, X-Forwarded-For, X-Real-Ip)
from requests originating from untrusted proxies at the HTTP
server level, reusing the existing proxy-protocol trusted-proxies
config. The clientip package is now a pure extraction helper;
context plumbing and middleware wrappers are removed.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-14 18:50:10 +04:00
parent 8f2426602b
commit e3ab373a0c
6 changed files with 329 additions and 26 deletions

View File

@@ -47,7 +47,6 @@ func NewMux(
r := chi.NewMux()
r.Use(newCORSMiddleware(logger, cookieBannerSvc))
r.Use(clientip.NewMiddleware())
r.Get("/{bannerID}/config", h.handleGetConfig)
r.Get("/{bannerID}/consents/{visitorID}", h.handleGetConsent)
r.Post("/{bannerID}/consents", h.handlePostConsent)
@@ -140,7 +139,7 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
return
}
ip := clientip.FromContext(r.Context())
ip := clientip.Extract(r)
ua := r.UserAgent()
req := cookiebanner.RecordConsentRequest{