Skip to content

Conversation

@fmorg-git
Copy link
Contributor

Please describe your PR in detail:

  • Connect S3 Gateway STS Endpoint to Backend OzoneManager Processing
  • Add configuration flag check in OzoneManager so STS assume role call is disallowed if configuration flag is not true. Also ensure non-native authorizer is being used as well.
  • A future PR will move duplicate constants and STS validation methods from the endpoint and backend OzoneManager to a shared location.

What is the link to the Apache JIRA

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

How was this patch tested?

unit tests and smoke testing

@fmorg-git fmorg-git changed the base branch from master to HDDS-13323-sts January 21, 2026 04:35
@ChenSammi ChenSammi added the sts Changes for Ozone's S3 Security Token Service label Jan 21, 2026
}

@Test
public void testAssumeRoleRejectedWhenStsEnabledAndNativeAuthorizerNotUsed() {
Copy link
Contributor

Choose a reason for hiding this comment

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

testAssumeRoleRejectedWhenStsEnabledAndNativeAuthorizerNotUsed ->

testAssumeRoleAllowedWhenStsEnabledAndNativeAuthorizerNotUsed

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 21381a9

if (queryParams == null) {
return null;
}
final String stsQueryParam = queryParams.getFirst("X-Amz-Security-Token");
Copy link
Contributor

Choose a reason for hiding this comment

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

Since "X-Amz-Security-Token" is case insensitive, it's better to loop the queryParams, and use the compareToIgnoreCase to compare the parameter name.

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 21381a9

Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(chars.charAt(random.nextInt(chars.length())));
final String requestId = UUID.randomUUID().toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we return the requestId from OM, and add the requestId in assumeRole audit log?

.build();
}

final AssumeRoleResponseInfo responseInfo = getClient()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better we catch the exception from assumeRole() and generateAssumeRoleResponse(), wrap it as OS3Exception to return.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like audit log is not supported in S3AssumeRoleRequest currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe in case of signature mismatch, we should catch OMException too

Copy link
Contributor Author

@fmorg-git fmorg-git Jan 27, 2026

Choose a reason for hiding this comment

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

updated - per internal communication, I identified that the endpoint was returning plain text instead of XML, so I revamped the error handling to use a new OSTSException that conforms to AWS XML structure. It distinguishes between signature mismatch and access denied similar to AWS bdb33a4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like audit log is not supported in S3AssumeRoleRequest currently.

updated - per internal communication, I mentioned with @len548 that I'll add the audit log here 85c38d0

final String accountId = parts[4];
final String resource = parts[5]; // role/<name>

if (accountId == null || accountId.isEmpty() || resource == null || !resource.startsWith("role/") ||
Copy link
Contributor

Choose a reason for hiding this comment

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

You can leverage Strings.isNullOrEmpty() for string null and empty check. Strings.isNullOrEmpty is wildly used in Ozone.

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 21381a9

@len548
Copy link
Contributor

len548 commented Jan 26, 2026

I think we can remove all the appearance of OS3Exception in S3STSEndpoint class. While developing in the previous PR, I added them to handle errors in endpoint. Later I replaced the way to handle errors with XML format instead of OS3Exception and I forgot to remove them. Can you remove them please?

@fmorg-git
Copy link
Contributor Author

I think we can remove all the appearance of OS3Exception in S3STSEndpoint class. While developing in the previous PR, I added them to handle errors in endpoint. Later I replaced the way to handle errors with XML format instead of OS3Exception and I forgot to remove them. Can you remove them please?

Per internal communication, I noticed recently the endpoint was returning plain text for errors when it should have been returning XML. The OS3Exception has an error XML format, but testing against AWS STS shows the error response XML structure for STS errors is slightly different than for S3 errors, so I revamped the error handling in this commit bdb33a4

@fmorg-git
Copy link
Contributor Author

This PR is getting a little big and unwieldy - I will close this and break it up into multiple PRs.

  1. Just connect the endpoint and Ozone manager and a few small PR comment updates (i.e. ce3e85c and 21381a9)
  2. Revamp the error handling in the endpoint to conform the AWS XML (i.e. bdb33a4)
  3. Add audit log to S3G and OM and correlate requestID between them (i.e. 85c38d0 and future work to correlate requestID)

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