xunliu commented on code in PR #5113:
URL: https://github.com/apache/gravitino/pull/5113#discussion_r1806684683
##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationPlugin.java:
##########
@@ -522,36 +657,35 @@ private boolean
doRemoveSecurableObject(RoleChange.RemoveSecurableObject change)
return true;
}
- /**
- * 1. Find the policy base the metadata object. <br>
- * 2. If the policy exists, then user new securable object's privilege to
update. <br>
- * 3. If the policy does not exist, return false. <br>
- */
- private boolean doUpdateSecurableObject(RoleChange.UpdateSecurableObject
change) {
- RangerPolicy policy =
rangerHelper.findManagedPolicy(change.getSecurableObject());
- if (policy == null) {
- LOG.warn(
- "Cannot find the Ranger policy({}) for the Gravitino securable
object({})!",
- change.getRoleName(),
- change.getSecurableObject().fullName());
- // Don't throw exception or return false, because need support immutable
operation.
- return false;
- }
-
- rangerHelper.removePolicyItem(policy, change.getRoleName(),
change.getSecurableObject());
- rangerHelper.addPolicyItem(policy, change.getRoleName(),
change.getNewSecurableObject());
- try {
- if (policy.getId() == null) {
- rangerClient.createPolicy(policy);
- } else {
- rangerClient.updatePolicy(policy.getId(), policy);
- }
- } catch (RangerServiceException e) {
- throw new RuntimeException(e);
- }
- return true;
- }
-
@Override
public void close() throws IOException {}
+
+ public boolean validAuthorizationOperation(List<SecurableObject>
securableObjects) {
+ return securableObjects.stream()
+ .noneMatch(
+ securableObject -> {
+ AtomicBoolean match = new AtomicBoolean(true);
+ securableObject.privileges().stream()
+ .forEach(
+ privilege -> {
+ if (!allowPrivilegesRule().contains(privilege.name()))
{
+ LOG.error(
+ "Authorization to ignore privilege({}) on
metadata object({})!",
Review Comment:
The input privilege is not in the list of allowed privileges, so it needs to
be ignored, and the error log output.
--
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]