sodonnel commented on code in PR #9372:
URL: https://github.com/apache/ozone/pull/9372#discussion_r2585691543


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequest.java:
##########
@@ -168,11 +169,39 @@ public OzoneManagerProtocolProtos.UserInfo getUserInfo() 
throws IOException {
     OzoneManagerProtocolProtos.UserInfo.Builder userInfo =
         OzoneManagerProtocolProtos.UserInfo.newBuilder();
 
-    // If S3 Authentication is set, determine user based on access ID.
+    // If S3 Authentication is set, determine user based on STS token first,
+    // falling back to accessId if session token not present.
     if (omRequest.hasS3Authentication()) {
-      String principal = OzoneAclUtils.accessIdToUserPrincipal(
-          omRequest.getS3Authentication().getAccessId());
-      userInfo.setUserName(principal);
+      final String accessKeyId = omRequest.getS3Authentication().getAccessId();
+      if (accessKeyId.startsWith("ASIA") && 
!omRequest.getS3Authentication().hasSessionToken()) {
+        throw new IOException("Error with STS token", new 
AuthenticationException(
+            "Missing session token for accessKeyId: " + accessKeyId));
+      }
+      if (omRequest.getS3Authentication().hasSessionToken()) {
+        try {
+          final STSTokenIdentifier stsTokenIdentifier = 
OzoneManager.getStsTokenIdentifier();
+          if (stsTokenIdentifier != null) {
+            final String originalAccessKeyId = 
stsTokenIdentifier.getOriginalAccessKeyId();

Review Comment:
   You might be able to reuse the static  
`OzoneManager.getS3AuthEffectiveAccessId()` to reduce a bit of repeated code 
here? See if you think it makes sense?



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