yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908056016


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, 
Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String 
resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   What I 'm trying to say: Is this a proper way to solve this problem?  If the 
path is very long, say have the item may be very large. 
   
   In the example above, I can use the prefix condition of the path to control 
the permission in IAM, so I wonder If we can do similar operation in for 
credentails.



-- 
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]

Reply via email to