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

Make it easier to reflect over FileDescriptors in an interceptor. #2978

Closed
hsyed opened this issue Aug 15, 2019 · 1 comment
Closed

Make it easier to reflect over FileDescriptors in an interceptor. #2978

hsyed opened this issue Aug 15, 2019 · 1 comment

Comments

@hsyed
Copy link

hsyed commented Aug 15, 2019

I'm working on interceptors to validate scopes in auth tokens for endpoints. We have proto options defined on the endpoints which specify valid scopes. I need to reflect over the descriptors to get access to the options.

However, the only way to walk the schema of the services defined in a server is via a *grpc.Server. The *grpc.Server is not passed into the interceptor and the descriptors (ServiceDescriptor / MethodDescriptor/ ....) are not available in the interceptors either.

I cannot initialise an interceptor with a server because it needs to be passed into the server as an option. The server has no lifecycle hooks that would let the interceptors be lazily registered before startup. There is a clunky workaround to this:

inter := &interceptor{}
srv := grpc.NewServer(grpc.UnaryInterceptor(inter))
inter.server = srv // <-- eventually use this to lazy load the schema from the server on first use

Would it be possible to have one of the following:

  • Have lifecycle hooks to register interceptors before Serve() --i.e., func(s *grpc.Server) []grpc.ServerOption ?
  • Have access to the relevant descriptors in the interceptors.
  • Have access to the server object in the interceptors.
@dfawley
Copy link
Member

dfawley commented Aug 15, 2019

This is a duplicate of #1526

@dfawley dfawley closed this as completed Aug 15, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants