-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
in: coreAn issue in spring-security-coreAn issue in spring-security-coretype: enhancementA general enhancementA general enhancement
Milestone
Description
To compose two authorization managers, some boilerplate is necessary. For example, to achieve a logical "or" between two authorization managers, they can be composed like so:
(authentication, object) -> {
AuthorizationDecision decision = this.first.check(authentication, object);
if (decision != null && decision.isGranted()) {
return decision;
}
return this.second.check(authentication, object);
}
It would be nice to have an easy way to compose authorization managers in an "any" or "all" fashion, similar to the AffirmativeBased
and UnanimousBased
access decision managers.
One way to do this would be to introduce a static class AuthorizationManagers
with convenience methods like so:
public static <T> AuthorizationManager<T> any(AuthorizationManager<T>... authorizationManagers);
public static <T> AuthorizationManager<T> all(AuthorizationManager<T>... authorizationManagers);
Then, the above code could be simplified to:
AuthorizationManagers.any(this.first, this.second);
sjohnr and evgeniycheban
Metadata
Metadata
Assignees
Labels
in: coreAn issue in spring-security-coreAn issue in spring-security-coretype: enhancementA general enhancementA general enhancement