diff --git a/weed/security/filer_client_auth.go b/weed/security/filer_client_auth.go index 8349392ac7..72142fedb5 100644 --- a/weed/security/filer_client_auth.go +++ b/weed/security/filer_client_auth.go @@ -189,8 +189,7 @@ func WithFilerSubscriptionToken(ctx context.Context, source FilerTokenSource) (c // bearer with admin authority. It preserves deadlines, cancellation and all // unrelated metadata, without modifying the original context's metadata. func WithFilerToken(ctx context.Context, source FilerTokenSource) (context.Context, error) { - md, _ := metadata.FromOutgoingContext(ctx) - if _, supplied := md["authorization"]; supplied || source == nil { + if source == nil || metadata.ValueFromOutgoingContext(ctx, "authorization") != nil { return ctx, nil } token, err := source(ctx) @@ -200,9 +199,7 @@ func WithFilerToken(ctx context.Context, source FilerTokenSource) (context.Conte if token == "" { return ctx, nil } - md = md.Copy() - md.Set("authorization", BearerPrefix+string(token)) - return metadata.NewOutgoingContext(ctx, md), nil + return metadata.AppendToOutgoingContext(ctx, "authorization", BearerPrefix+string(token)), nil } // WithFilerClientAuth wraps a connection interface for one logical client,