What version of gRPC are you using?
1.15.0
I would like to use SpringSecurity to secure my grpc service.
public class TestService extends TestServiceGrpc.TestServiceImplBase {
@Override
@Secured("ROLE_USER")
public void getVersion(Empty request, StreamObserver<Version> responseObserver) {
responseObserver.onNext(Version.newBuilder().setVersion("1337.42").build());
responseObserver.onCompleted();
}
}
(The authentication and exception handling is done via interceptors.)
However if I do that I get one of two issues.
-
First, the default way of Spring to apply the value is using an interface based proxy. This will cause
io.grpc.StatusRuntimeException: UNIMPLEMENTED: Method not found: TestService/getVersion
errors because the actual methods aren't present in any interface.
-
I can avoid that error by using an AOP based proxy, but if I do that, then I get a warning in the logs:
WARN CglibAopProxy - Unable to proxy interface-implementing method [public final io.grpc.ServerServiceDefinition TestServiceGrpc$TestServiceImplBase.bindService()] because it is marked as final: Consider using interface-based JDK proxies instead!
The error was introduced by: #2552 / #2553
Possible solutions:
- Manually create an interface for that 😒 .
- Remove final modifier from that method 😐 .
- Let grpc-java create an interface for that 👍 . (Used as a proxy or to be implemented via ImplBase)
- Switch to java 8 (or later) and convert the ImplBase to an interface (combines 2+3) 👍 😄 .
PS: I used Spring-Security as an example, but the same issues apply for any kind of annotation based runtime code injection. Such as method call parameter logging, timing/metrics...
What version of gRPC are you using?
1.15.0
I would like to use SpringSecurity to secure my grpc service.
(The authentication and exception handling is done via interceptors.)
However if I do that I get one of two issues.
First, the default way of Spring to apply the value is using an interface based proxy. This will cause
errors because the actual methods aren't present in any interface.
I can avoid that error by using an AOP based proxy, but if I do that, then I get a warning in the logs:
WARN CglibAopProxy - Unable to proxy interface-implementing method [public final io.grpc.ServerServiceDefinition TestServiceGrpc$TestServiceImplBase.bindService()] because it is marked as final: Consider using interface-based JDK proxies instead!The error was introduced by: #2552 / #2553
Possible solutions:
PS: I used Spring-Security as an example, but the same issues apply for any kind of annotation based runtime code injection. Such as method call parameter logging, timing/metrics...