Skip to content

Commit 3f7355a

Browse files
committed
Synthesize all annotation attributes
Issue gh-14601
1 parent 560665d commit 3f7355a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

config/src/test/java/org/springframework/security/config/annotation/method/configuration/MethodSecurityService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public Object postProcessResult(MethodInvocationResult methodInvocationResult,
305305
@Target({ ElementType.METHOD, ElementType.TYPE })
306306
@Retention(RetentionPolicy.RUNTIME)
307307
@Inherited
308-
@PostAuthorize(value = "hasRole('{value}')", postProcessorClass = NullPostProcessor.class)
308+
@PostAuthorize(value = "hasRole('{role}')", postProcessorClass = NullPostProcessor.class)
309309
@interface NullDenied {
310310

311311
String role();

config/src/test/java/org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfigurationTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,9 @@ void postAuthorizeWhenHandlerAndAccessDeniedNotThrownFromPostAuthorizeThenNotHan
827827
@Test
828828
@WithMockUser
829829
void postAuthorizeWhenNullDeniedMetaAnnotationThanWorks() {
830-
this.spring.register(MethodSecurityServiceEnabledConfig.class, MethodSecurityService.NullPostProcessor.class)
830+
this.spring
831+
.register(MethodSecurityServiceEnabledConfig.class, MetaAnnotationPlaceholderConfig.class,
832+
MethodSecurityService.NullPostProcessor.class)
831833
.autowire();
832834
MethodSecurityService service = this.spring.getContext().getBean(MethodSecurityService.class);
833835
String result = service.postAuthorizeDeniedWithNullDenied();

core/src/main/java/org/springframework/security/authorization/method/AuthorizationAnnotationUtils.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.AnnotatedElement;
2121
import java.lang.reflect.Method;
22-
import java.util.Collections;
2322
import java.util.HashMap;
2423
import java.util.List;
2524
import java.util.Map;
@@ -76,7 +75,9 @@ static <A extends Annotation> Function<AnnotatedElement, A> withDefaults(Class<A
7675
}
7776
AnnotatedElement annotatedElement = (AnnotatedElement) mergedAnnotation.getSource();
7877
String value = helper.replacePlaceholders(expression, stringProperties::get);
79-
return MergedAnnotation.of(annotatedElement, type, Collections.singletonMap("value", value)).synthesize();
78+
Map<String, Object> properties = new HashMap<>(mergedAnnotation.asMap());
79+
properties.put("value", value);
80+
return MergedAnnotation.of(annotatedElement, type, properties).synthesize();
8081
};
8182
return (annotatedElement) -> findDistinctAnnotation(annotatedElement, type, map);
8283
}

0 commit comments

Comments
 (0)