-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-10775. Support bucket ownership verification #8558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
cef94c9
HDDS-10775. Support bucket ownership verification
hevinhsu 219933b
HDDS-10775. Add integration test
hevinhsu e385d1e
HDDS-10775. Fix error
hevinhsu 05468b9
Merge branch 'apache:master' into HDDS-10775
hevinhsu 0a0f166
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu 4281392
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu 0204224
Move integration tests to AbstractS3SDKV2Tests to avoid duplicated mi…
hevinhsu 6d83496
fix spotbug warning
hevinhsu 35d962d
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu 6d07294
Feat: add null bucketOwner verification
hevinhsu a779f77
Fix: fix check style
hevinhsu 2888c76
Refactor: move BucketOwnerCondition static method to S3Owner
hevinhsu f9c807c
Fix: fix checkstyle
hevinhsu 145b2b0
Refactor: rename method name
hevinhsu 6e9b763
chore: recover non-necessary changes
hevinhsu 31c460b
Fix: fix build failed
hevinhsu 54c4a94
feat: add error entry for bucket owner verification failure
hevinhsu 7972065
Revert non relative changes
hevinhsu 3c9f721
Refactor: merge bucket owner verification tests to reduce setup dupli…
hevinhsu 8084bca
Feat: add link bucket integration tests
hevinhsu f1863a8
Fix: fix check style
hevinhsu 41ea401
Revert: revert non relative changes
hevinhsu 5745682
Remove bucket owner condition unit tests because these scenario cover…
hevinhsu 660f2e6
refactor: simplify implementation to minimize code changes
hevinhsu 23835f2
Fix typo
hevinhsu ae642b3
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu 2c2d8c7
Rename testcase names
hevinhsu 059932b
Refactor: add new BucketEndpoint attribute: headers to replace HttpHe…
hevinhsu 9d41ae9
Fix typo
hevinhsu 3ad3aa1
Refactor: ignore destBucket owner verification to because it's alread…
hevinhsu 3bec8cd
Refactor: simplify method call to get omMultipartUploadCompleteInfo
hevinhsu f42ba39
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu 97d7dca
Add correct resource name on S3Error when exception occur on copy ope…
hevinhsu e66d702
Fix: fix findbugs warning
hevinhsu 92d346b
Merge remote-tracking branch 'origin/master' into HDDS-10775
hevinhsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
616 changes: 616 additions & 0 deletions
616
...tion-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,10 +17,15 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package org.apache.hadoop.ozone.s3.endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.ws.rs.core.HttpHeaders; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.xml.bind.annotation.XmlAccessType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.xml.bind.annotation.XmlAccessorType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.xml.bind.annotation.XmlElement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.xml.bind.annotation.XmlRootElement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.commons.lang3.StringUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.hadoop.ozone.s3.exception.OS3Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.hadoop.ozone.s3.exception.S3ErrorTable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.hadoop.ozone.s3.util.S3Consts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Represents an owner of S3 resources in the Ozone S3 compatibility layer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -80,4 +85,59 @@ public String toString() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ", id='" + id + '\'' + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Verify the bucket owner condition. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param headers HTTP headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param bucketName bucket name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param bucketOwner bucket owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @throws OS3Exception if the expected bucket owner does not match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void verifyBucketOwnerCondition(HttpHeaders headers, String bucketName, String bucketOwner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throws OS3Exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (headers == null || bucketOwner == null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String expectedBucketOwner = headers.getHeaderString(S3Consts.EXPECTED_BUCKET_OWNER_HEADER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (StringUtils.isEmpty(expectedBucketOwner)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (expectedBucketOwner.equals(bucketOwner)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw S3ErrorTable.newError(S3ErrorTable.BUCKET_OWNER_MISMATCH, bucketName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+97
to
+112
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Verify the bucket owner condition on copy operation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param headers HTTP headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param sourceBucketName source bucket name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param sourceOwner source bucket owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param destBucketName dest bucket name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param destOwner destination bucket owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @throws OS3Exception if the expected source or destination bucket owner does not match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void verifyBucketOwnerConditionOnCopyOperation(HttpHeaders headers, String sourceBucketName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String sourceOwner, String destBucketName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String destOwner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throws OS3Exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (headers == null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String expectedSourceOwner = headers.getHeaderString(S3Consts.EXPECTED_SOURCE_BUCKET_OWNER_HEADER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String expectedDestOwner = headers.getHeaderString(S3Consts.EXPECTED_BUCKET_OWNER_HEADER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (expectedSourceOwner != null && sourceOwner != null && !sourceOwner.equals(expectedSourceOwner)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw S3ErrorTable.newError(S3ErrorTable.BUCKET_OWNER_MISMATCH, sourceBucketName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (expectedDestOwner != null && destOwner != null && !destOwner.equals(expectedDestOwner)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw S3ErrorTable.newError(S3ErrorTable.BUCKET_OWNER_MISMATCH, destBucketName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+142
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to remove
getBucketduplication. Can be addressed in a follow up.