question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EnableGlobalMethodSecurity stops ability to use GrpcClient

See original GitHub issue

This 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:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
fgarsombkecommented, Feb 12, 2022

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.

0reactions
e7868acommented, Apr 2, 2022

GlobalMethodSecurityConfiguration implements SmartInitializingSingleton, it is created early than GrpcClientBeanPostProcessorGrpcClientBeanPostProcessor 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。

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found