go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

Reflection with gRPC Auth

Open dtaniwaki opened this issue 4 years ago • 5 comments

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.

dtaniwaki avatar Nov 06 '19 15:11 dtaniwaki

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 avatar Nov 06 '19 17:11 johanbrandhorst

@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?

dtaniwaki avatar Nov 07 '19 01:11 dtaniwaki

Nah you're right you can't wrap that. Maybe raise an issue against gRPC-go?

johanbrandhorst avatar Nov 07 '19 10:11 johanbrandhorst

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?

dtaniwaki avatar Nov 08 '19 01:11 dtaniwaki

I think you can get the method name from the context somehow. Take a look at the grpc-go documentation.

johanbrandhorst avatar Nov 08 '19 09:11 johanbrandhorst