@@ -47,7 +47,6 @@ import (
4747 "github.com/kcp-dev/kcp/pkg/cache/client/shard"
4848 "github.com/kcp-dev/kcp/pkg/endpointslice"
4949 "github.com/kcp-dev/kcp/pkg/indexers"
50- "github.com/kcp-dev/kcp/pkg/proxy/authheaders"
5150 "github.com/kcp-dev/kcp/pkg/reconciler/dynamicrestmapper"
5251 kcpfilters "github.com/kcp-dev/kcp/pkg/server/filters"
5352)
@@ -405,26 +404,13 @@ func newVirtualResourceHandler(cfg *rest.Config, vwURL, clusterNameOrWildcard st
405404 Transport : tr ,
406405 Rewrite : func (r * httputil.ProxyRequest ) {
407406 r .SetURL (scopedURL )
407+ r .SetXForwarded ()
408+ // SetURL clears the outbound Host along with pointing the request at
409+ // the virtual workspace; keep the host the caller asked for, which is
410+ // what a single-host reverse proxy forwards.
411+ r .Out .Host = r .In .Host
412+
408413 hops .SetHeader (r .Out .Header , inboundHops + 1 )
409- // Say who asked.
410- //
411- // The connection to the virtual workspace authenticates as this shard,
412- // so without this the virtual workspace sees the shard and authorizes
413- // that instead of the caller -- and a provider's backend is told the
414- // shard's identity rather than the user's. The virtual workspace
415- // believes these headers only over a connection whose client
416- // certificate its --requestheader-client-ca-file trusts, which is the
417- // same arrangement the front proxy already uses to reach shards.
418- //
419- // Stamping strips any inbound copies first, so a client cannot assert
420- // an identity by setting the headers itself.
421- if user , ok := genericapirequest .UserFrom (r .Out .Context ()); ok {
422- authheaders .SetAuthHeaders (r .Out .Header , user ,
423- authheaders .DefaultUserHeader , authheaders .DefaultGroupHeader , authheaders .DefaultExtraHeaderPrefix )
424- } else {
425- authheaders .ClearAuthHeaders (r .Out .Header ,
426- authheaders .DefaultUserHeader , authheaders .DefaultGroupHeader , authheaders .DefaultExtraHeaderPrefix )
427- }
428414 },
429415 }
430416
0 commit comments