fmorg-git commented on code in PR #9894:
URL: https://github.com/apache/ozone/pull/9894#discussion_r2998255297


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ListStatusLightOptions.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.client.protocol;
+
+import java.util.Objects;
+
+/**
+ * Options for {@link ClientProtocol#listStatusLight(ListStatusLightOptions)}.
+ * Encapsulates all parameters to allow future extensibility without breaking
+ * the method signature.
+ */
+public final class ListStatusLightOptions {
+
+  private final String volumeName;
+  private final String bucketName;
+  private final String keyName;
+  private final boolean recursive;
+  private final String startKey;
+  private final long numEntries;
+  private final boolean allowPartialPrefixes;
+  // When keyName is empty (root listing), this is the original S3/list
+  // prefix for STS auth. Enables LIST check on this prefix instead of "*".
+  private final String listPrefix;

Review Comment:
   ok great, thanks for catching that.  Hopefully that answers your suggestion 
here: https://github.com/apache/ozone/pull/9894#discussion_r2964268585.  Per 
comment above, this is why I created a brand new parameter `listPrefix` that no 
one is using and will only be used for STS - it is safer and prevents 
regressions like this.  I updated the commit to go back to the original 
implementation that incorporated your first two comments.
   
   > I'm not quite get what's the permission issue here, is it that you don't 
want to grant user READ permission on bucket?
   
   Per the original PR comment, there are multiple issues.  Having this 
`listPrefix` will help with number 1 (and to a lesser extent to number 4):
   1 - Support passing list prefix on root listing so STS can authorize against 
it.
   
   Perhaps it's not clear what the issue with number 1 is.  
   
   Suppose there is a `bucket123` bucket in S3 that has the following files:
   ```
   userM/m1.txt
   userS/s1.txt
   userF/f1.txt
   userU/u1.txt
   userP/p1.txt
   ```
   
   Now an admin wants to give `userF` an STS token so `userF` can list *only* 
the files under the `userF/` folder (so they should NOT be able to see `userS` 
files or `userP` files, etc).   The admin could give this IAM policy when 
creating the STS token:
   
   ```
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Action": "s3:ListBucket",
         "Resource": "arn:aws:s3:::bucket123",
         "Condition": {
           "StringLike": {
             "s3:prefix": "userF/*"
           }
         }
       }
     ]
   }
   ```
   
   Now `userF` has STS token that admin generated and is making S3 api calls.  
If the user invokes list-objects-v2 calls like 
`http://bucket123.s3.amazonaws.com/?list-type=2&prefix=userF` or 
`http://bucket123.s3.amazonaws.com/?list-type=2` or 
`http://bucket123.s3.amazonaws.com/?list-type=2&prefix=userM` etc, they must 
get AccessDenied error according to AWS behavior.  Only if they invoke 
`http://bucket123.s3.amazonaws.com/?list-type=2&prefix=userF/` (note the slash 
at the end matches the `s3:prefix` in the IAM policy) should it be allowed to 
succeed and they would only see the `userF/f1.txt` file.
   
   Without this patch and follow-on patches (that's why this is part 1), some 
of the api invocations above that should get AccessDenied error will not 
happen.  This is a security issue because it means they would be able to see 
files they should not be able to see.
   
   Will it help clarity if instead of `listPrefix`, I called the parameter 
`originalS3PrefixParameter` or something like that? Essentially, I need to know 
what the `prefix` parameter is in the S3 call so I can authorize against it to 
see if it matched the `s3:prefix` from the IAM session policy.



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

Reply via email to