Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forwarding HTTP Headers as gRPC Context Metadata #19

Open
alehechka opened this issue Aug 5, 2022 · 0 comments
Open

Forwarding HTTP Headers as gRPC Context Metadata #19

alehechka opened this issue Aug 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@alehechka
Copy link
Owner

Through experimentation with authenticated requests through the gateway to the gRPC server, it was found that this gateway does not forward HTTP headers via gRPC Context Metadata as the grpc-gateway does.

This is a massive shortcoming due to the general requirement that authorization and other header analysis should be performed at the gRPC service instance or at the very least with gRPC middleware.

Examining the grpc-gateway's implementation, it appears that all predefined HTTP headers are prepended with the grpcgateway- prefix, likely because these can and will be passed along in standard gRPC requests. Additionally, any custom headers beyond the predefined HTTP ones must be prepended with Grpc-Metadata- during the REST request to the gateway and the prefix will be removed before appending the header and its value to the gRPC context metadata.

It would be nice to simply add grpc-gateway as a dependency to this library to be able to make use of what it already has available, but the code is dependent on set up outside of the AnnotateContext function which would make it impossible to use out of the box and importing it would make for a weird dependency tree.

Instead, the code available in grpc-gateway should be used as inspiration in creating a custom HTTP header forwarding solution for the grpc-graphql-gateway.

@alehechka alehechka added the enhancement New feature or request label Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant