mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-12 05:13:33 +00:00
Support AliasFor
Closes gh-15436
This commit is contained in:
parent
03bcc6776a
commit
e3438aa36a
@ -136,11 +136,7 @@ final class AuthorizationAnnotationUtils {
|
|||||||
Class<A> annotationType, Function<MergedAnnotation<A>, A> map) {
|
Class<A> annotationType, Function<MergedAnnotation<A>, A> map) {
|
||||||
MergedAnnotations mergedAnnotations = MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY,
|
MergedAnnotations mergedAnnotations = MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY,
|
||||||
RepeatableContainers.none());
|
RepeatableContainers.none());
|
||||||
List<A> annotations = mergedAnnotations.stream(annotationType)
|
List<A> annotations = mergedAnnotations.stream(annotationType).map(map).distinct().toList();
|
||||||
.map(MergedAnnotation::withNonMergedAttributes)
|
|
||||||
.map(map)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return switch (annotations.size()) {
|
return switch (annotations.size()) {
|
||||||
case 0 -> null;
|
case 0 -> null;
|
||||||
|
@ -90,11 +90,7 @@ class AuthorizationAnnotationUtilsTests {
|
|||||||
void composedMergedAnnotationsAreNotSupported() {
|
void composedMergedAnnotationsAreNotSupported() {
|
||||||
Class<?> clazz = ComposedPreAuthAnnotationOnClass.class;
|
Class<?> clazz = ComposedPreAuthAnnotationOnClass.class;
|
||||||
PreAuthorize preAuthorize = AuthorizationAnnotationUtils.findUniqueAnnotation(clazz, PreAuthorize.class);
|
PreAuthorize preAuthorize = AuthorizationAnnotationUtils.findUniqueAnnotation(clazz, PreAuthorize.class);
|
||||||
|
assertThat(preAuthorize.value()).isEqualTo("hasRole('composedRole')");
|
||||||
// If you comment out .map(MergedAnnotation::withNonMergedAttributes) in
|
|
||||||
// AuthorizationAnnotationUtils.findDistinctAnnotation(), the value of
|
|
||||||
// the merged annotation would be "hasRole('composedRole')".
|
|
||||||
assertThat(preAuthorize.value()).isEqualTo("hasRole('metaRole')");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface BaseRepository<T> {
|
private interface BaseRepository<T> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user