-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Is your feature request related to a problem?
I'm trying to enable e2e encryption in grpc sever side using Marshallers. There is a very handy ServerInterceptors#useMarshalledMessages(ServerServiceDefinition, MethodDescriptor.Marshaller) that allows me to specify marshaller that can intercept request and response and modify it before passing bytes to serialization and actual sever processing logic. The problem that I have is that for e2e encryption I need to perform different actions: for request it is decryption and for response it is encryption. Thus I need to separate marshallers: one for requests(doing decryption) and another one for responses(doing encryption).
Describe the solution you'd like
Add(aka override) existing method ServerInterceptors#useMarshalledMessages(ServerServiceDefinition, MethodDescriptor.Marshaller) to be ServerInterceptors#useMarshalledMessages(ServerServiceDefinition, MethodDescriptor.Marshaller, MethodDescriptor.Marshaller).
Describe alternatives you've considered
There are couple alternatives to enable e2e encryption in grpc server, how ever they all have drawbacks:
- Use Compressors with custom codecs to do encryption/decryption.
Drawback: it is not what compressors are meant to be used for and they fit the e2e encryption use case poorly, despite the fact there is a way to make e2e encryption to work with codecs. - Shift all the code to generate needed
ServerServiceDefinitionoutside of the grpc.io library. In other words, don't changeServerInterceptors.javain grpc.io, but instead createServerServiceDefinitionwith e2e encryption marshallers in the code that uses grpc.io and just just pass thisServerServiceDefinitionto server builder when grpc server is built.
Drawback: unlike withServerInterceptors.javacase, creation of suchServerServiceDefinitionoutside ofServerInterceptors.javawill require significant amount of code to be written. TheServerInterceptors.javahas a lot of helper methods that are not public and will have to be almost fully copy-pasted(including several of non public methods and classes outside ofServerInterceptors.javathat available toServerInterceptors.javabut not to the code that uses grpc.io) to the code of application that wants to enable e2e encryption for grpc server.
Additional context
n/a