From c8485fca86a1e73c889d6ab4aaafe66fb0ac91f2 Mon Sep 17 00:00:00 2001 From: Neelesh Thakur Date: Wed, 6 Dec 2023 10:34:50 -0700 Subject: [PATCH] PWX-35277: copy auth token to the outgoing gRPC metadata Need to explicitly copy the auth token to the outgoing gRPC metadata when forwarding the request to another node. Signed-off-by: Neelesh Thakur --- api/server/sdk/volume_migrate.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/server/sdk/volume_migrate.go b/api/server/sdk/volume_migrate.go index dca0591d3..1723314e6 100644 --- a/api/server/sdk/volume_migrate.go +++ b/api/server/sdk/volume_migrate.go @@ -27,6 +27,10 @@ import ( "google.golang.org/grpc/status" ) +const ( + authorizationKey = "authorization" +) + // Start a volume migration func (s *VolumeServer) Start( ctx context.Context, @@ -43,6 +47,11 @@ func (s *VolumeServer) Start( // Forward the request to some other node and set the context metadata so that // the request is terminated at the receiving node. rctx := metadata.AppendToOutgoingContext(ctx, ContextRoundRobinTerminateKey, "true") + // append auth + auth := md.Get(authorizationKey) + if len(auth) > 0 { + rctx = metadata.AppendToOutgoingContext(rctx, authorizationKey, auth[0]) + } remoteConn, remote, err := s.balancer().GetRemoteNodeConnection(rctx) if err == nil && remote { return api.NewOpenStorageMigrateClient(remoteConn).Start(rctx, req)