You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: remove call credentials from call options if DirectPath (#3670)
This PR eliminates the issue where call credentials get attached twice
to a RPC in DirectPath cases. Particularly, when user credentials get
used, the problem causes the RPC to fail due to the duplication of the
quota project ID (internal-only context:
[b/364288002](http://b/364288002)).
The approach is to strip the credentials in the callOptions returned by
the `GrpcCallContext` if the `TransportChannel` is DirectPath. The side
effect is that users won't be able to configure call credentials via the
`ApiCallContext` if DirectPath is used.
We think this is acceptable because:
1. Users can still configure the credentials via
`TransportChannelProvider.withCredentials()`. At a higher level, this is
done by configuring the `CredentialsProvider` in the `StubSettings` or
the `ServiceOptions`.
2. As of now, DirectPath has its own special authentication flow, in
which the service account attached to the GCE VM or GKE Pod will be
used. Although in some special cases, the call credentials will be used
to authenticate the client's identity, the peculiar nature of DirectPath
should justify us limiting the flexibility of how call credentials can
be configured in this case.
## Tested DirectPath using Spanner
Headers sent
```
[:authority: spanner.googleapis.com, :path: /google.spanner.v1.Spanner/BatchCreateSessions, :method: POST, :scheme: https, content-type: application/grpc, te: trailers, user-agent: spanner-java/6.86.0 grpc-java-netty/1.69.0, ..., grpc-accept-encoding: gzip, authorization: Bearer ya29.****, ..., authorization: Bearer 1234, grpc-timeout: 56962080u]
```
Bearer token is sent twice (first `ya29.***` value is valid and second
`1234` is invalid). The second one was attached by customizing the
ApiCallContext to send an invalid CallCredentials as part of the
CallOptions. The call still succeeded as the first Bearer token in the
Metadata is used.
0 commit comments