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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/STSSecurityUtil.java:
##########
@@ -213,23 +217,116 @@ public static void 
ensureResolvedStsFieldsInvariants(OzoneManagerProtocolProtos.
 
     if (!hasSessionToken) {
       // If sessionToken is missing/empty, resolved fields must be empty.
-      if (s3Auth.hasResolvedStsSessionPolicy() || 
s3Auth.hasResolvedStsRoleArn() ||
-          s3Auth.hasResolvedStsOriginalAccessKeyId() || 
s3Auth.hasResolvedStsTempAccessKeyId() ||
-          s3Auth.hasResolvedStsSecretKeyId()) {
+      if (hasAnyResolvedStsField(s3Auth)) {
         throw new OMException("Resolved STS fields must be empty when 
sessionToken is not present", INVALID_TOKEN);
       }
       return;
     }
 
-    ensureResolvedFieldsArePresent(s3Auth);
+    if (!hasAllResolvedStsFields(s3Auth)) {
+      throw new OMException("Resolved STS fields must be present when 
sessionToken is present", INVALID_TOKEN);
+    }
+  }
+
+  private static boolean hasAnyResolvedStsField(S3Authentication s3Auth) {
+    return s3Auth.hasResolvedStsSessionPolicy() || 
s3Auth.hasResolvedStsRoleArn() ||
+        s3Auth.hasResolvedStsOriginalAccessKeyId() || 
s3Auth.hasResolvedStsTempAccessKeyId() ||
+        s3Auth.hasResolvedStsSecretKeyId() || 
s3Auth.hasResolvedStsAssumedRoleId() ||
+        s3Auth.hasResolvedStsAssumedRoleUserArn();
   }
 
-  private static void ensureResolvedFieldsArePresent(S3Authentication s3Auth) 
throws OMException {
-    if (!s3Auth.hasResolvedStsSessionPolicy() || 
!s3Auth.hasResolvedStsRoleArn() ||
-        !s3Auth.hasResolvedStsOriginalAccessKeyId() || 
!s3Auth.hasResolvedStsTempAccessKeyId() ||
-        !s3Auth.hasResolvedStsSecretKeyId()) {
-      throw new OMException("Resolved STS fields must be present when 
sessionToken is present", INVALID_TOKEN);
+  private static boolean hasAllResolvedStsFields(S3Authentication s3Auth) {

Review Comment:
   updated - made `resolvedStsAssumedRoleId` and `resolvedStsAssumedRoleUserArn 
`optional in `hasAllResolvedStsFields()` since they're for GetCallerIdentity, 
not apply-path ACL.



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