Skip to content

Commit

Permalink
Set prefix, delimiter params even when empty
Browse files Browse the repository at this point in the history
We have never set values which are empty on the request
because they are perhaps not useful in the List query,
but this assumption is wrong when there are restricted
policies for a given user, because empty is actually
a valid value in IAM or Bucket policy conditions.

For example following condition would never work with our
ListObjects call and AWS cli would work fine.

            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "",
                        "data/",
                        "data"
                    ],
                    "s3:delimiter": [
                        "/",
                        ""
                    ]
                }
            }

The reason is empty or not prefix and delimiter should be
added to the query param in List operation, such that server
can use the value to validate the policies for the incoming
request.

Refer minio/minio-go#1064
  • Loading branch information
harshavardhana authored and minio-trusted committed Jan 30, 2019
1 parent 75c9320 commit a397035
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions api/src/main/java/io/minio/MinioClient.java
@@ -1,6 +1,6 @@
/*
* Minio Java SDK for Amazon S3 Compatible Cloud Storage,
* (C) 2015, 2016, 2017 Minio, Inc.
* (C) 2015, 2016, 2017, 2018, 2019 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -3019,10 +3019,14 @@ private ListBucketResult listObjectsV2(String bucketName, String continuationTok

if (prefix != null) {
queryParamMap.put("prefix", prefix);
} else {
queryParamMap.put("prefix", "");
}

if (delimiter != null) {
queryParamMap.put("delimiter", delimiter);
} else {
queryParamMap.put("delimiter", "");
}

HttpResponse response = executeGet(bucketName, null, null, queryParamMap);
Expand Down Expand Up @@ -3186,10 +3190,14 @@ private ListBucketResultV1 listObjectsV1(String bucketName, String marker, Strin

if (prefix != null) {
queryParamMap.put("prefix", prefix);
} else {
queryParamMap.put("prefix", "");
}

if (delimiter != null) {
queryParamMap.put("delimiter", delimiter);
} else {
queryParamMap.put("delimiter", "");
}

HttpResponse response = executeGet(bucketName, null, null, queryParamMap);
Expand Down Expand Up @@ -4672,10 +4680,26 @@ private ListMultipartUploadsResult listIncompleteUploads(String bucketName, Stri
Map<String,String> queryParamMap = new HashMap<>();
queryParamMap.put("uploads", "");
queryParamMap.put("max-uploads", Integer.toString(maxUploads));
queryParamMap.put("prefix", prefix);
queryParamMap.put("key-marker", keyMarker);
queryParamMap.put("upload-id-marker", uploadIdMarker);
queryParamMap.put("delimiter", delimiter);

if (prefix != null) {
queryParamMap.put("prefix", prefix);
} else {
queryParamMap.put("prefix", "");
}

if (delimiter != null) {
queryParamMap.put("delimiter", delimiter);
} else {
queryParamMap.put("delimiter", "");
}

if (keyMarker != null) {
queryParamMap.put("key-marker", keyMarker);
}

if (uploadIdMarker != null) {
queryParamMap.put("upload-id-marker", uploadIdMarker);
}

HttpResponse response = executeGet(bucketName, null, null, queryParamMap);

Expand Down

0 comments on commit a397035

Please sign in to comment.