commit
b62dd851a2
|
@ -41,11 +41,17 @@ public final class AuthorizationManagers {
|
|||
List<AuthorizationDecision> decisions = new ArrayList<>();
|
||||
for (AuthorizationManager<T> manager : managers) {
|
||||
AuthorizationDecision decision = manager.check(authentication, object);
|
||||
if (decision == null || decision.isGranted()) {
|
||||
if (decision == null) {
|
||||
continue;
|
||||
}
|
||||
if (decision.isGranted()) {
|
||||
return decision;
|
||||
}
|
||||
decisions.add(decision);
|
||||
}
|
||||
if (decisions.isEmpty()) {
|
||||
return new AuthorizationDecision(false);
|
||||
}
|
||||
return new CompositeAuthorizationDecision(false, decisions);
|
||||
};
|
||||
}
|
||||
|
@ -64,11 +70,17 @@ public final class AuthorizationManagers {
|
|||
List<AuthorizationDecision> decisions = new ArrayList<>();
|
||||
for (AuthorizationManager<T> manager : managers) {
|
||||
AuthorizationDecision decision = manager.check(authentication, object);
|
||||
if (decision != null && !decision.isGranted()) {
|
||||
if (decision == null) {
|
||||
continue;
|
||||
}
|
||||
if (!decision.isGranted()) {
|
||||
return decision;
|
||||
}
|
||||
decisions.add(decision);
|
||||
}
|
||||
if (decisions.isEmpty()) {
|
||||
return new AuthorizationDecision(true);
|
||||
}
|
||||
return new CompositeAuthorizationDecision(true, decisions);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,12 +36,14 @@ class AuthorizationManagersTests {
|
|||
assertThat(decision.isGranted()).isTrue();
|
||||
}
|
||||
|
||||
// gh-13069
|
||||
@Test
|
||||
void checkAnyOfWhenOneAbstainedThenAbstainedDecision() {
|
||||
void checkAnyOfWhenAllNonAbstainingDeniesThenDeniedDecision() {
|
||||
AuthorizationManager<?> composed = AuthorizationManagers.anyOf((a, o) -> new AuthorizationDecision(false),
|
||||
(a, o) -> null);
|
||||
AuthorizationDecision decision = composed.check(null, null);
|
||||
assertThat(decision).isNull();
|
||||
assertThat(decision).isNotNull();
|
||||
assertThat(decision.isGranted()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,8 +63,9 @@ class AuthorizationManagersTests {
|
|||
assertThat(decision.isGranted()).isTrue();
|
||||
}
|
||||
|
||||
// gh-13069
|
||||
@Test
|
||||
void checkAllOfWhenOneAbstainedThenGrantedDecision() {
|
||||
void checkAllOfWhenAllNonAbstainingGrantsThenGrantedDecision() {
|
||||
AuthorizationManager<?> composed = AuthorizationManagers.allOf((a, o) -> new AuthorizationDecision(true),
|
||||
(a, o) -> null);
|
||||
AuthorizationDecision decision = composed.check(null, null);
|
||||
|
|
Loading…
Reference in New Issue