From 57fb22e7b49b7da1f4af76cb2dcbeffcf6a4766b Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Mon, 12 Jun 2023 15:00:55 +0200 Subject: [PATCH] Pass along basic auth credentials Some Prometheus/Thanos/... instances might need it, so let's support it. See https://prometheus.io/docs/prometheus/latest/configuration/https/#https-and-authentication for some details. --- prom-revisionist.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/prom-revisionist.go b/prom-revisionist.go index c1bb26e..bf70d94 100644 --- a/prom-revisionist.go +++ b/prom-revisionist.go @@ -137,6 +137,11 @@ func main() { } proxyReq.Header = req.Header + username, password, ok := req.BasicAuth() + if ok { + proxyReq.SetBasicAuth(username, password) + } + resp, err := http.DefaultClient.Do(proxyReq) if err != nil { log.Printf("failed to created request: %s", err) @@ -241,6 +246,11 @@ func main() { } proxyReq.Header = req.Header + username, password, ok := req.BasicAuth() + if ok { + proxyReq.SetBasicAuth(username, password) + } + resp, err := http.DefaultClient.Do(proxyReq) if err != nil { log.Printf("failed to created request: %s", err)