Fix @EnableGlobalAuthentication & method seucrity on @Configuration class
Fixes gh-3934
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.context.annotation.Import
|
||||
import org.springframework.core.Ordered
|
||||
import org.springframework.core.annotation.Order
|
||||
import org.springframework.security.access.annotation.Secured
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.authentication.AuthenticationManager
|
||||
import org.springframework.security.authentication.AuthenticationProvider
|
||||
import org.springframework.security.authentication.TestingAuthenticationToken
|
||||
@@ -485,4 +486,33 @@ class AuthenticationConfigurationTests extends BaseSpringSpec {
|
||||
UDS
|
||||
}
|
||||
}
|
||||
|
||||
def 'EnableGlobalMethodSecurity configuration uses PreAuthorize does not cause BeanCurrentlyInCreationException'() {
|
||||
when:
|
||||
loadConfig(UsesPreAuthorizeMethodSecurityConfig,AuthenticationManagerBeanConfig)
|
||||
then:
|
||||
noExceptionThrown()
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
static class UsesPreAuthorizeMethodSecurityConfig {
|
||||
@PreAuthorize("denyAll")
|
||||
void run() {}
|
||||
}
|
||||
|
||||
|
||||
def 'EnableGlobalMethodSecurity uses method security service'() {
|
||||
when:
|
||||
loadConfig(ServicesConfig,UsesPreAuthorizeMethodSecurityConfig,AuthenticationManagerBeanConfig)
|
||||
then:
|
||||
noExceptionThrown()
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
static class UsesServiceMethodSecurityConfig {
|
||||
@Autowired
|
||||
Service service
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user