Skip to content

Commit 7a233c4

Browse files
dodgexjzheaux
authored andcommitted
Some infrastructure beans are not marked properly
Added missing infrastructure role to methodSecurityMetadataSource bean and move the post processing of the defaultMethodExpressionHandler to the end of afterSingletonsInstantiated. Closes gh-9845
1 parent c294050 commit 7a233c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -174,6 +174,8 @@ public void afterSingletonsInstantiated() {
174174
if (grantedAuthorityDefaults != null) {
175175
this.defaultMethodExpressionHandler.setDefaultRolePrefix(grantedAuthorityDefaults.getRolePrefix());
176176
}
177+
178+
this.defaultMethodExpressionHandler = this.objectPostProcessor.postProcess(this.defaultMethodExpressionHandler);
177179
}
178180

179181
private <T> T getSingleBeanOrNull(Class<T> type) {
@@ -338,6 +340,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
338340
* @return the {@link MethodSecurityMetadataSource}
339341
*/
340342
@Bean
343+
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
341344
public MethodSecurityMetadataSource methodSecurityMetadataSource() {
342345
List<MethodSecurityMetadataSource> sources = new ArrayList<>();
343346
ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory(
@@ -397,7 +400,6 @@ public final void setImportMetadata(AnnotationMetadata importMetadata) {
397400
@Autowired(required = false)
398401
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
399402
this.objectPostProcessor = objectPostProcessor;
400-
this.defaultMethodExpressionHandler = objectPostProcessor.postProcess(this.defaultMethodExpressionHandler);
401403
}
402404

403405
@Autowired(required = false)

0 commit comments

Comments
 (0)