Skip to content

Commit

Permalink
PWX-35277: copy auth token to the outgoing gRPC metadata
Browse files Browse the repository at this point in the history
Need to explicitly copy the auth token to the outgoing gRPC metadata when
forwarding the request to another node.

Signed-off-by: Neelesh Thakur <[email protected]>
  • Loading branch information
pureneelesh committed Dec 6, 2023
1 parent 759bca7 commit c8485fc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/server/sdk/volume_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"google.golang.org/grpc/status"
)

const (
authorizationKey = "authorization"
)

// Start a volume migration
func (s *VolumeServer) Start(
ctx context.Context,
Expand All @@ -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)
Expand Down

0 comments on commit c8485fc

Please sign in to comment.