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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user