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

@@ -64,6 +64,7 @@ import (
"go.probo.inc/probo/pkg/probo"
"go.probo.inc/probo/pkg/securecookie"
"go.probo.inc/probo/pkg/server"
"go.probo.inc/probo/pkg/server/trustedproxy"
"go.probo.inc/probo/pkg/slack"
"go.probo.inc/probo/pkg/trust"
"go.probo.inc/probo/pkg/webhook"
@@ -768,6 +769,9 @@ func (impl *Implm) runApiServer(
ctx, span := tracer.Start(ctx, "probod.runApiServer")
defer span.End()
trustedProxies := parseIPs(impl.cfg.Api.ProxyProtocol.TrustedProxies)
handler = trustedproxy.NewMiddleware(trustedProxies)(handler)
apiServer := httpserver.NewServer(
impl.cfg.Api.Addr,
handler,