You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PrePostMethodSecurityConfiguration is missing a setter for custom PermissionEvaluator #19084
Describe the bug PrePostMethodSecurityConfiguration takes in account custom GrantedAuthorityDefaults, RoleHierarchy and AuthorizationManagerFactory beans but ignores custom PermissionEvaluator bean.
To Reproduce
Setup a context with a custom permission evaluator, for instance PrePostMethodSecurityConfigurationTests with:
@Configuration
@EnableMethodSecurity
static class CustomPermissionEvaluatorConfig {
@Bean
PermissionEvaluator permissionEvaluator() {
return new PermissionEvaluator() {
@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject,
Object permission) {
return "grant".equals(targetDomainObject);
}
@Override
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
Object permission) {
throw new UnsupportedOperationException();
}
};
}
}
=> custom PermissionEvaluator bean is not injected into PrePostMethodSecurityConfiguration's default expression handler and following test fails:
@WithMockUser
@Test
public void postHasPermissionWhenParameterIsGrantThenPasses() {
this.spring.register(CustomPermissionEvaluatorConfig.class, MethodSecurityServiceConfig.class).autowire();
String result = this.methodSecurityService.postHasPermission("grant");
assertThat(result).isNull();
}
Expected behavior
Custom permission evaluator should be injected in PrePostMethodSecurityConfiguration's default expression handler.
Activity
Allow injection of custom PermissionEvaluator in PrePostMethodSecurit…
Siggen commentedon Apr 16, 2026
Candidate fix in gh-19085.
jzheaux commentedon Sep 3, 2026
Thanks for the PR, @Siggen. I'll close this in favor of continuing the conversation in #19085.
Allow injection of custom PermissionEvaluator in PrePostMethodSecurit…
Pick Up PermissionEvaluator Bean
Pick Up PermissionEvaluator Bean
Upgrade to Spring Boot 4.2