From 81fec0c82ada94651196bc3d8171d71163ac66d9 Mon Sep 17 00:00:00 2001 From: Oleksii Khaliavka Date: Tue, 9 May 2023 04:31:28 +0300 Subject: [PATCH] fix: rewrite Host header in dex round tripper Signed-off-by: Oleksii Khaliavka --- util/dex/dex.go | 1 + util/dex/dex_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/util/dex/dex.go b/util/dex/dex.go index 71183f5c30d21..3116909a32ee1 100644 --- a/util/dex/dex.go +++ b/util/dex/dex.go @@ -123,6 +123,7 @@ type DexRewriteURLRoundTripper struct { func (s DexRewriteURLRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) { r.URL.Host = s.DexURL.Host r.URL.Scheme = s.DexURL.Scheme + r.Host = s.DexURL.Host return s.T.RoundTrip(r) } diff --git a/util/dex/dex_test.go b/util/dex/dex_test.go index 015907379b3cc..ed7dc6bc6e45c 100644 --- a/util/dex/dex_test.go +++ b/util/dex/dex_test.go @@ -429,5 +429,7 @@ func Test_DexReverseProxy(t *testing.T) { assert.NoError(t, err) _, err = rt.RoundTrip(req) assert.NoError(t, err) + target, _ := url.Parse(server.URL) + assert.Equal(t, req.Host, target.Host) }) }