go-grpc-middleware
go-grpc-middleware copied to clipboard
Reflection with gRPC Auth
I'd like to use reflection google.golang.org/grpc/reflection
with gRPC auth of the middlewares. As the reflection service is defined in the library, it's not possible to override the auth function.
Could you help me the best way to utilize both?
I wanted to exclude /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
from my authentication logic but it was not possible because the auth func doesn't take method name.
Hi Daisuke!
I think you might be able to define a shallow wrapper around the reflection service implementation, and register that? Then you can define the AuthFunc on your wrapper.
Does that work?
@johanbrandhorst Thank you for the reply. I wanted to do it but the reflection package doesn't expose anything. https://github.com/grpc/grpc-go/blob/0aa47d32dae466606c4f6200663093be54dbc7b2/reflection/serverreflection.go#L59
Maybe, my golang knowledge is not perfect. Could you tell me how to wrap this kind of unexposed objects?
Nah you're right you can't wrap that. Maybe raise an issue against gRPC-go?
That’s also an option. Is it possible to pass operation name to the regular auth function so we can filter requests by operation name?
I think you can get the method name from the context somehow. Take a look at the grpc-go documentation.