martinweiler commented on code in PR #3655:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3655#discussion_r1752667490
##########
api/kogito-api/src/main/java/org/kie/kogito/auth/SecurityPolicy.java:
##########
@@ -55,9 +63,46 @@ protected SecurityPolicy(IdentityProvider identity) {
this.identity = identity;
}
+ public String getUser() {
+ return identity.getName();
+ }
+
+ public Collection<String> getRoles() {
+ return identity.getRoles();
+ }
+
+ @Override
+ public void enforce(KogitoWorkItem workItem) {
+ if (workItem.getActualOwner() != null &&
workItem.getActualOwner().equals(getUser())) {
+ return;
+ }
+
+ String actualOwner = workItem.getActualOwner();
+ String actualOwners = (String) workItem.getParameter("ActorId");
+ String actualRoles = (String) workItem.getParameter("GroupId");
+ String excludedOwner = (String)
workItem.getParameter("ExcludedOwnerId");
+ if (actualOwners != null || actualRoles != null) {
+ List<String> owners = actualOwners != null ? new
ArrayList<>(List.of(actualOwners.split(","))) : new ArrayList<>();
+ List<String> excluded = excludedOwner != null ? new
ArrayList<>(List.of(excludedOwner.split(","))) : new ArrayList<>();
+ owners.removeAll(excluded);
+ List<String> roles = actualRoles != null ?
List.of(actualRoles.split(",")) : new ArrayList<>();
+ List<String> userRoles = new ArrayList<>(identity.getRoles());
+ userRoles.retainAll(roles);
+ LOGGER.info("enforcing identity {} and roles {} with potential
owners {} and potential groups {} and exclude groups {}",
Review Comment:
Shouldn't this be at debug level only?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]