bharos commented on code in PR #10867:
URL: https://github.com/apache/gravitino/pull/10867#discussion_r3140708093
##########
server-common/src/main/java/org/apache/gravitino/server/authorization/jcasbin/JcasbinAuthorizer.java:
##########
@@ -601,4 +609,45 @@ private void loadPolicyByRoleEntity(RoleEntity roleEntity)
{
}
}
}
+
+ /**
+ * Checks whether the given principal is the owner of the metadata object
identified by
+ * metadataId. Supports both user and group ownership.
+ */
+ private boolean checkOwnership(Principal principal, String metalake, Long
metadataId) {
+ Optional<OwnerInfo> ownerOpt = ownerRel.getIfPresent(metadataId);
+ if (ownerOpt == null || !ownerOpt.isPresent()) {
+ return false;
+ }
+ OwnerInfo owner = ownerOpt.get();
+ if (owner.type == Entity.EntityType.USER) {
+ try {
+ UserEntity userEntity = getUserEntity(principal.getName(), metalake);
+ return Objects.equals(userEntity.id(), owner.id);
Review Comment:
Good point. Then in the group name as well, I think I should actually
involve an extra IO operation, for same use-case of removing and adding same
name for group ?
--
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]