From b6a0404efdec125aeac320e2c54d0cfbd9d26def Mon Sep 17 00:00:00 2001 From: mathieuHa Date: Tue, 16 Apr 2024 13:26:46 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20user-agent=20header=20from=20?= =?UTF-8?q?crowdsec=20(#149)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add user-agent header from crowdsec * 🐛 : https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/issues/151 --------- Co-authored-by: maxlerebourg --- bouncer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bouncer.go b/bouncer.go index 7fbf562..82a3f38 100644 --- a/bouncer.go +++ b/bouncer.go @@ -28,6 +28,7 @@ const ( crowdsecAppsecHostHeader = "X-Crowdsec-Appsec-Host" crowdsecAppsecVerbHeader = "X-Crowdsec-Appsec-Verb" crowdsecAppsecHeader = "X-Crowdsec-Appsec-Api-Key" + crowdsecAppsecUserAgent = "X-Crowdsec-Appsec-User-Agent" crowdsecLapiHeader = "X-Api-Key" crowdsecLapiRoute = "v1/decisions" crowdsecLapiStreamRoute = "v1/decisions/stream" @@ -586,7 +587,8 @@ func appsecQuery(bouncer *Bouncer, ip string, httpReq *http.Request) error { req.Header.Set(crowdsecAppsecIPHeader, ip) req.Header.Set(crowdsecAppsecVerbHeader, httpReq.Method) req.Header.Set(crowdsecAppsecHostHeader, httpReq.Host) - req.Header.Set(crowdsecAppsecURIHeader, httpReq.URL.Path) + req.Header.Set(crowdsecAppsecURIHeader, httpReq.URL.String()) + req.Header.Set(crowdsecAppsecUserAgent, httpReq.Header.Get("User-Agent")) res, err := bouncer.httpClient.Do(req) if err != nil {