mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 01:02:14 +00:00
Synthesize all annotation attributes
Issue gh-14601
This commit is contained in:
parent
560665d575
commit
3f7355abc6
@ -305,7 +305,7 @@ public interface MethodSecurityService {
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@PostAuthorize(value = "hasRole('{value}')", postProcessorClass = NullPostProcessor.class)
|
||||
@PostAuthorize(value = "hasRole('{role}')", postProcessorClass = NullPostProcessor.class)
|
||||
@interface NullDenied {
|
||||
|
||||
String role();
|
||||
|
@ -827,7 +827,9 @@ public class PrePostMethodSecurityConfigurationTests {
|
||||
@Test
|
||||
@WithMockUser
|
||||
void postAuthorizeWhenNullDeniedMetaAnnotationThanWorks() {
|
||||
this.spring.register(MethodSecurityServiceEnabledConfig.class, MethodSecurityService.NullPostProcessor.class)
|
||||
this.spring
|
||||
.register(MethodSecurityServiceEnabledConfig.class, MetaAnnotationPlaceholderConfig.class,
|
||||
MethodSecurityService.NullPostProcessor.class)
|
||||
.autowire();
|
||||
MethodSecurityService service = this.spring.getContext().getBean(MethodSecurityService.class);
|
||||
String result = service.postAuthorizeDeniedWithNullDenied();
|
||||
|
@ -19,7 +19,6 @@ package org.springframework.security.authorization.method;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -76,7 +75,9 @@ final class AuthorizationAnnotationUtils {
|
||||
}
|
||||
AnnotatedElement annotatedElement = (AnnotatedElement) mergedAnnotation.getSource();
|
||||
String value = helper.replacePlaceholders(expression, stringProperties::get);
|
||||
return MergedAnnotation.of(annotatedElement, type, Collections.singletonMap("value", value)).synthesize();
|
||||
Map<String, Object> properties = new HashMap<>(mergedAnnotation.asMap());
|
||||
properties.put("value", value);
|
||||
return MergedAnnotation.of(annotatedElement, type, properties).synthesize();
|
||||
};
|
||||
return (annotatedElement) -> findDistinctAnnotation(annotatedElement, type, map);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user