File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed
main/java/org/springframework/security/authorization
test/java/org/springframework/security/authorization Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,17 @@ public static <T> AuthorizationManager<T> anyOf(AuthorizationManager<T>... manag
41
41
List <AuthorizationDecision > decisions = new ArrayList <>();
42
42
for (AuthorizationManager <T > manager : managers ) {
43
43
AuthorizationDecision decision = manager .check (authentication , object );
44
- if (decision == null || decision .isGranted ()) {
44
+ if (decision == null ) {
45
+ continue ;
46
+ }
47
+ if (decision .isGranted ()) {
45
48
return decision ;
46
49
}
47
50
decisions .add (decision );
48
51
}
52
+ if (decisions .isEmpty ()) {
53
+ return new AuthorizationDecision (false );
54
+ }
49
55
return new CompositeAuthorizationDecision (false , decisions );
50
56
};
51
57
}
@@ -64,11 +70,17 @@ public static <T> AuthorizationManager<T> allOf(AuthorizationManager<T>... manag
64
70
List <AuthorizationDecision > decisions = new ArrayList <>();
65
71
for (AuthorizationManager <T > manager : managers ) {
66
72
AuthorizationDecision decision = manager .check (authentication , object );
67
- if (decision != null && !decision .isGranted ()) {
73
+ if (decision == null ) {
74
+ continue ;
75
+ }
76
+ if (!decision .isGranted ()) {
68
77
return decision ;
69
78
}
70
79
decisions .add (decision );
71
80
}
81
+ if (decisions .isEmpty ()) {
82
+ return new AuthorizationDecision (true );
83
+ }
72
84
return new CompositeAuthorizationDecision (true , decisions );
73
85
};
74
86
}
Original file line number Diff line number Diff line change @@ -36,12 +36,14 @@ void checkAnyOfWhenOneGrantedThenGrantedDecision() {
36
36
assertThat (decision .isGranted ()).isTrue ();
37
37
}
38
38
39
+ // gh-13069
39
40
@ Test
40
- void checkAnyOfWhenOneAbstainedThenAbstainedDecision () {
41
+ void checkAnyOfWhenAllNonAbstainingDeniesThenDeniedDecision () {
41
42
AuthorizationManager <?> composed = AuthorizationManagers .anyOf ((a , o ) -> new AuthorizationDecision (false ),
42
43
(a , o ) -> null );
43
44
AuthorizationDecision decision = composed .check (null , null );
44
- assertThat (decision ).isNull ();
45
+ assertThat (decision ).isNotNull ();
46
+ assertThat (decision .isGranted ()).isFalse ();
45
47
}
46
48
47
49
@ Test
@@ -61,8 +63,9 @@ void checkAllOfWhenAllGrantedThenGrantedDecision() {
61
63
assertThat (decision .isGranted ()).isTrue ();
62
64
}
63
65
66
+ // gh-13069
64
67
@ Test
65
- void checkAllOfWhenOneAbstainedThenGrantedDecision () {
68
+ void checkAllOfWhenAllNonAbstainingGrantsThenGrantedDecision () {
66
69
AuthorizationManager <?> composed = AuthorizationManagers .allOf ((a , o ) -> new AuthorizationDecision (true ),
67
70
(a , o ) -> null );
68
71
AuthorizationDecision decision = composed .check (null , null );
You can’t perform that action at this time.
0 commit comments