tonic icon indicating copy to clipboard operation
tonic copied to clipboard

authentication example incompatible with grpcurl and grpcui (when token doesn't match)

Open ebiggs opened this issue 4 years ago • 1 comments

Bug Report

Version

fresh clone of master, running authentication example's server

Platform

Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Description

When executing

 grpcurl -v -plaintext -import-path . -proto echo.proto -H 'authorization: Bearer some-secret-token' -d '{ "message": "Hello World" }' localhost:50051 grpc.examples.echo.Echo.UnaryEcho

I get a happy result:

Resolved method descriptor:
// UnaryEcho is unary echo.
rpc UnaryEcho ( .grpc.examples.echo.EchoRequest ) returns ( .grpc.examples.echo.EchoResponse );

Request metadata to send:
authorization: Bearer some-secret-token

Response headers received:
content-type: application/grpc
date: Mon, 06 Sep 2021 00:15:30 GMT

Response contents:
{
  "message": "Hello World"
}

Response trailers received:
(empty)
Sent 1 request and received 1 response

However when I execute this, changing just the token

grpcurl -v -plaintext -import-path . -proto echo.proto -H 'authorization: Bearer not-a-secret' -d '{ "message": "Hello World" }' localhost:50051 grpc.examples.echo.Echo.UnaryEcho

I get this unexpected result:

Resolved method descriptor:
// UnaryEcho is unary echo.
rpc UnaryEcho ( .grpc.examples.echo.EchoRequest ) returns ( .grpc.examples.echo.EchoResponse );

Request metadata to send:
authorization: Bearer not-a-secret

Response headers received:
(empty)

Response trailers received:
(empty)
Sent 1 request and received 0 responses
ERROR:
  Code: Unknown
  Message: OK: HTTP status code 200; transport: missing content-type field

My expectations are to get an "unauthencated" status code and the message: "No valid auth token" per line 66 of tonic/examples/src/authentication/server.rs.

ebiggs avatar Sep 06 '21 00:09 ebiggs

Turns out that this isn't an issue in other grpc clients, just grpcurl and grpcui. Haven't tested other Go-lang gRPC clients more broadly. I've abandoned grpcurl now in favor of a home grown cli client written with gRPC-js. This issue may remain as a marker to support grpcurl/grpcui, or it can be closed if that's not a goal.

ebiggs avatar Oct 07 '21 23:10 ebiggs