Added metadata via AsyncAuthInterceptor; why isn't it passed to the server?

30 views
Skip to first unread message

alawrenc...@gmail.com

unread,
Mar 29, 2019, 8:40:12 AM3/29/19
to grpc.io
Example code using Grpc.Core 1.19.0:

var asyncAuthInterceptor = new AsyncAuthInterceptor((context, metadata) =>
{
    metadata.Add("jwtToken", GetToken());
    return Task.CompletedTask;
});

var gRpcClient = new MyService.MyServiceClient(new Channel($"127.0.0.1:{port}", ChannelCredentials.Insecure));
gRpcClient.Ping(new PingMessage(), new CallOptions(credentials: CallCredentials.FromInterceptor(asyncAuthInterceptor)));

When I debug into the server's Ping method implementation, I can't see a jwtToken in any of the exposed properties on the ServerCallContext. Is this where I should expect to see it? If so, is it expected that this metadata would be ignored/removed?

Jan Tattermusch

unread,
Apr 4, 2019, 2:48:04 AM4/4/19
to grpc.io
You cannot pass an auth token over an insecure channel - because your token would be sent on the wire in plain text and can be stolen by anyone and gRPC protects you against this kind of error by refusing to send the auth token over an insecure channel.
Use secure channel and things will work.
if you enable extra logging (see https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md) you'll probably see a warning.
Reply all
Reply to author
Forward
0 new messages