From 6f3afb810df00992c08e84c10607b426c04303d3 Mon Sep 17 00:00:00 2001 From: Livio Spring Date: Wed, 6 Dec 2023 18:53:41 +0200 Subject: [PATCH] fix: use host with potential port for instance context (#7022) --- internal/api/http/middleware/instance_interceptor.go | 2 +- internal/api/http/middleware/instance_interceptor_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/http/middleware/instance_interceptor.go b/internal/api/http/middleware/instance_interceptor.go index 3e4fd41f69..e04ca9f7ab 100644 --- a/internal/api/http/middleware/instance_interceptor.go +++ b/internal/api/http/middleware/instance_interceptor.go @@ -111,7 +111,7 @@ func hostFromOrigin(ctx context.Context) (host string, err error) { if err != nil { return "", err } - host = u.Hostname() + host = u.Host if host == "" { err = errors.New("empty host") } diff --git a/internal/api/http/middleware/instance_interceptor_test.go b/internal/api/http/middleware/instance_interceptor_test.go index e61fade72d..5273d2fd58 100644 --- a/internal/api/http/middleware/instance_interceptor_test.go +++ b/internal/api/http/middleware/instance_interceptor_test.go @@ -221,7 +221,7 @@ func Test_setInstance(t *testing.T) { r.Header.Set("host", "fromrequest") return r.WithContext(zitadel_http.WithComposedOrigin(r.Context(), "https://fromorigin:9999")) }(), - verifier: &mockInstanceVerifier{"fromorigin"}, + verifier: &mockInstanceVerifier{"fromorigin:9999"}, headerName: "host", }, res{