-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
grpc gateway intercepter #785
Comments
I think you can achieve this today without writing anything new in grpc-gateway by using eitehr a grpc client interceptor or a server interceptor in the destination server. Can you help me understand why this needs to be added to the routing framework over hooking into the preexisting interceptors? |
@achew22 I want to do authorization for requests only in apigateway , and grpc client interceptor can do that. It's what I'm looking for. So it's not needed add intercepter in apigateway. Thanks! |
@wongoo Perfect! Thanks so much for following up. Would you be willing to write a little bit up? If so, we could put it as a FAQ in our documentation so that future users won't have to struggle quite as much. What do you think of that? |
Do authorization for requests in apigateway instead of grpc servers is more efficient , especially when grpc servers calling each others. Grpc client interceptor is a way to implement authorization, but it's called after the restful request proxied to grpc request. If the authorization can be done before proxying, performance maybe better. |
Personally the gateway seems the wrong place to add interceptors. It performs translation, not business logic. All of this belongs in the gRPC service it's talking to. |
@johanbrandhorst may be call it |
grpc-gateway provide a proxy mechanism , but no proxy intercepter.
A intercepter is a function called before method handler, the intercepter can get info about the definition of the method, like method path and so on.
The following is a scenario to use intercepter and how to design it.
I define a
google.protobuf.MethodOptions
namedallow_roles
in all methods, which is used for authorization.Then it can get a map whoes key is the full path of method, and value is the defined allow roles.
I think the authorization can be done in grpc-gateway.
First, add method path into handler and provide it when registering.
Second, add intercepter in ServeMux and provide method to initial it.
Third, call intercepter before calling handler:
The text was updated successfully, but these errors were encountered: