Skip to content

Conversation

@fmorg-git
Copy link
Contributor

@fmorg-git fmorg-git commented Nov 11, 2025

Please describe your PR in detail:

  • Introduce S3AssumeRoleRequest and S3AssumeRoleResponse

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-13888

How was this patch tested?

Unit tests

@sodonnel
Copy link
Contributor

Can you rebase this one now that #9254 is committed please?

@fmorg-git fmorg-git changed the base branch from master to HDDS-13323-sts November 12, 2025 21:07
@fmorg-git fmorg-git marked this pull request as ready for review November 12, 2025 21:33
@fmorg-git
Copy link
Contributor Author

**sodonnel **

@sodonnel I rebased the PR and put it in Ready for Review state.


// Expected format: arn:aws:iam::123456789012:role/[optional path segments/]RoleName
if (!roleArn.startsWith("arn:aws:iam::")) {
throw new OMException("Invalid role ARN: " + roleArn, OMException.ResultCodes.INVALID_REQUEST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding "does not start with ..." to the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// Split ARN into parts: arn:aws:iam::accountId:role/path/name
final String[] parts = roleArn.split(":", 6);
if (parts.length < 6 || !parts[5].startsWith("role/")) {
throw new OMException("Invalid role ARN: " + roleArn, OMException.ResultCodes.INVALID_REQUEST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, is it worth adding "unexpected field count" or something similar to this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated - I added more descriptive messages in other cases as well

* arn:aws:iam::123456789012:role/path/RoleB -> RoleB
*/
@VisibleForTesting
static String validateAndExtractRoleNameFromArn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like the logic to validate and extract parts of the Arn could be a class of its own. However I am happy if you leave it as it is, but if we have other areas of the code that need to decode this in the future, or extra different fields, perhaps keep in mind that this can be extracted into a standalone class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

);

// TODO sts - generate a real STS token in a future PR that incorporates the components above
return originalAccessKeyId + ":" + roleArn + ":" + assumeRoleRequest.getDurationSeconds() +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a String builder to avoid all the concatenations, but this is temporary code so leave it as it is for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


@Override
public void addToDBBatch(OMMetadataManager omMetadataManager,
BatchOperation batchOperation) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed reformatting this parameter to have 4 space indend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@sodonnel
Copy link
Contributor

Looks largely good. I left a few minor comments I thought of as I went through it.

@fmorg-git fmorg-git requested a review from sodonnel November 14, 2025 00:03
Copy link
Contributor

@sodonnel sodonnel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for making the changes. But there are javadoc failures in the CI:

Warning:  Javadoc Warnings
Warning:  /home/runner/work/ozone/ozone/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/AwsRoleArnValidator.java:38: warning - invalid usage of tag >
Warning:  /home/runner/work/ozone/ozone/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/AwsRoleArnValidator.java:39: warning - invalid usage of tag >

If you could fix those then we can commit it. Thanks!

@fmorg-git
Copy link
Contributor Author

hi @sodonnel - thanks - I believe I fixed the Javadoc issue and the CI issue. Can you please merge if everything looks ok? And also would you be able to merge upstream master into the feature branch HDDS-13323-sts after this merge so it doesn't get too old?

@errose28 errose28 added the sts Changes for Ozone's S3 Security Token Service label Nov 14, 2025
@sodonnel sodonnel merged commit 7eaebe6 into apache:HDDS-13323-sts Nov 14, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sts Changes for Ozone's S3 Security Token Service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants