-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Describe the bug
This is kind of a follow up to #8407. I just found that in my project there are two beans related to Method Security logged that they are not eligible for post processing.
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@6d2dc9d2' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
To Reproduce
As this also happens in a fresh project this is kind of easy to reproduce:
- go to start.spring.io
- create a spring boot 2.5.0 project (i'm sure other options are not relevant but i had maven+java11+jar)
- add following dependencies
- spring-data-jpa
- spring-security
- spring-web
- h2 database (to have a db for data-jpa)
- add
@EnableGlobalMethodSecurity(prePostEnabled = true)
to the application class - build & start the application
The issue only seems to occur with spring-web and spring-data-jpa (maybe other combinations too)
Expected behavior
Ideally the message should not be logged.
Additional Info
Adding a custom config extending GlobalMethodSecurityConfiguration
and overriding methodSecurityMetadataSource
to add the @Role
annotation allowed me to get rid of the related log message but I found no way to do this for the message related to DefaultMethodSecurityExpressionHandler
.
The custom config:
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.springframework.security.access.method.MethodSecurityMetadataSource;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
@Configuration
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
@Bean
@Override
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public MethodSecurityMetadataSource methodSecurityMetadataSource() {
return super.methodSecurityMetadataSource();
}
}
I'm not sure to what extend this is an actual issue as the security seems to work as expected. but as in the original issue #8407 and the #8429 there where attempts to work against these log messages and it is suggested that those INFO logs maybe should be warnings I thought I should mention it.