EnableGlobalMethodSecurity stops ability to use GrpcClient
See original GitHub issueThis works just fine…
@Configuration
public class AppConfig extends GlobalMethodSecurityConfiguration {
@GrpcClient("userService")
private UserServiceGrpc.UserServiceBlockingStub userService;
@Bean
public UserClient userClient() {
return new UserClientWrapper(userService);
}
But when security is added…
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AppConfig extends GlobalMethodSecurityConfiguration {
@GrpcClient("userService")
private UserServiceGrpc.UserServiceBlockingStub userService;
@Bean
public UserClient userClient() {
return new UserClientWrapper(userService);
}
the userService
is always null.
This also works without global security…
@Configuration
@GrpcClientBean(
clazz = UserServiceGrpc.UserServiceBlockingStub.class,
beanName = "userService",
client = @GrpcClient("userService"))
public class AppConfig extends GlobalMethodSecurityConfiguration {
@Bean
public UserClient userClient(@Qualifier("userService") final UserServiceGrpc.UserServiceBlockingStub userService) {
return new UserClientWrapper(userService);
}
But does not work with…
@Configuration
@GrpcClientBean(
clazz = UserServiceGrpc.UserServiceBlockingStub.class,
beanName = "userService",
client = @GrpcClient("userService"))
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AppConfig extends GlobalMethodSecurityConfiguration {
@Bean
public UserClient userClient(@Qualifier("userService") final UserServiceGrpc.UserServiceBlockingStub userService) {
return new UserClientWrapper(userService);
}
Thoughts?
Thank you in advance!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Server Security | grpc-spring-boot-starter - GitHub Pages
This section describes how you secure your application using transport layer security and authentication. We strongly recommend enabling at least transport ...
Read more >java - Disable EnableGlobalMethodSecurity annotation
I've managed this by defining a Spring "securityDisabled" profile and conditionally applying security config based off that. I'm using Spring Boot 2.0.2. I ......
Read more >Troubleshoot gRPC on .NET Core - Microsoft Learn
To work around this issue, configure Kestrel and the gRPC client to use HTTP/2 without TLS. You should only do this during development....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve determined its the combination of
extends GlobalMethodSecurityConfiguration
and@EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true)
that causes this issue.Without
extends GlobalMethodSecurityConfiguration
it works correctly.I will continue to investigate why the extends causes the null issue.
GlobalMethodSecurityConfiguration implements SmartInitializingSingleton, it is created early than GrpcClientBeanPostProcessor。GrpcClientBeanPostProcessor can’t process AppConfig and it’s dependency beans。
create stub bean with GrpcClientBean, use @Lazy to delay field inject。
Maybe GrpcClientBeanPostProcessor should implments PriorityOrdered to get higher priority。