You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "hdygxsj (via GitHub)" <gi...@apache.org> on 2025/08/01 10:06:03 UTC
[PR] [#7887]bug(authz): Fix list role names for metadata object API lack access control [gravitino]
hdygxsj opened a new pull request, #7898:
URL: https://github.com/apache/gravitino/pull/7898
### What changes were proposed in this pull request?
Fix list role names for metadata object API lack access control
### Why are the changes needed?
Fix: #7887
### Does this PR introduce _any_ user-facing change?
None
### How was this patch tested?
org.apache.gravitino.client.integration.test.authorization.MetadataObjectRoleAuthorizationIT
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "xunliu (via GitHub)" <gi...@apache.org>.
xunliu merged PR #7898:
URL: https://github.com/apache/gravitino/pull/7898
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7898:
URL: https://github.com/apache/gravitino/pull/7898#discussion_r2250361982
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
+ return MetadataFilterHelper.filterByExpression(
+ metalake,
+ "METALAKE::OWNER || ROLE::OWNER || ROLE::SELF",
Review Comment:
[nitpick] The authorization expression is hardcoded. Consider extracting this to a constant or configuration to improve maintainability and make it easier to modify access control rules.
```suggestion
ROLE_LIST_AUTHORIZATION_EXPRESSION,
```
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
Review Comment:
Creating a new array for each role name in the filter is inefficient. Consider reusing the array or using a more efficient approach for single element operations.
```suggestion
// Reuse a single-element array to avoid repeated allocations
final NameIdentifier[] nameIdentifiers = new NameIdentifier[1];
names =
Arrays.stream(names)
.filter(
role -> {
nameIdentifiers[0] = NameIdentifierUtil.ofRole(metalake, role);
```
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
+ return MetadataFilterHelper.filterByExpression(
+ metalake,
+ "METALAKE::OWNER || ROLE::OWNER || ROLE::SELF",
+ Entity.EntityType.ROLE,
+ nameIdentifiers)
+ .length
+ > 0;
+ })
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
Review Comment:
Converting to List and then back to array is inefficient. Consider using `toArray(String[]::new)` or collecting directly to an array to avoid unnecessary intermediate collection.
```suggestion
.toArray(String[]::new);
```
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "hdygxsj (via GitHub)" <gi...@apache.org>.
hdygxsj commented on code in PR #7898:
URL: https://github.com/apache/gravitino/pull/7898#discussion_r2250481220
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
Review Comment:
Will be optimized in https://github.com/apache/gravitino/issues/7914
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "hdygxsj (via GitHub)" <gi...@apache.org>.
hdygxsj commented on PR #7898:
URL: https://github.com/apache/gravitino/pull/7898#issuecomment-3149011364
> @hdygxsj Could you fix the failure of CI?
fixed
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "hdygxsj (via GitHub)" <gi...@apache.org>.
hdygxsj commented on code in PR #7898:
URL: https://github.com/apache/gravitino/pull/7898#discussion_r2250511526
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
+ return MetadataFilterHelper.filterByExpression(
+ metalake,
+ "METALAKE::OWNER || ROLE::OWNER || ROLE::SELF",
+ Entity.EntityType.ROLE,
+ nameIdentifiers)
+ .length
+ > 0;
+ })
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
Review Comment:
Will be optimized in https://github.com/apache/gravitino/issues/7914
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectRoleOperations.java:
##########
@@ -70,6 +76,22 @@ public Response listRoles(
httpRequest,
() -> {
String[] names = accessControlDispatcher.listRoleNamesByObject(metalake, object);
+ names =
+ Arrays.stream(names)
+ .filter(
+ role -> {
+ NameIdentifier[] nameIdentifiers =
+ new NameIdentifier[] {NameIdentifierUtil.ofRole(metalake, role)};
+ return MetadataFilterHelper.filterByExpression(
+ metalake,
+ "METALAKE::OWNER || ROLE::OWNER || ROLE::SELF",
Review Comment:
Will be optimized in https://github.com/apache/gravitino/issues/7914
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7887] fix(authz): Fix list role names for metadata object API lack access control [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #7898:
URL: https://github.com/apache/gravitino/pull/7898#issuecomment-3148946023
@hdygxsj Could you fix the failure of CI?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org