cccs-cat001 commented on code in PR #3170:
URL: https://github.com/apache/polaris/pull/3170#discussion_r2572295177


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsCredentialsStorageIntegration.java:
##########
@@ -90,35 +96,46 @@ public StorageAccessConfig getSubscopedCreds(
     StorageAccessConfig.Builder accessConfig = StorageAccessConfig.builder();
 
     if (shouldUseSts(storageConfig)) {
-      AssumeRoleRequest.Builder request =
-          AssumeRoleRequest.builder()
-              .externalId(storageConfig.getExternalId())
-              .roleArn(storageConfig.getRoleARN())
-              .roleSessionName("PolarisAwsCredentialsStorageIntegration")
-              .policy(
-                  policyString(
-                          storageConfig,
-                          allowListOperation,
-                          allowedReadLocations,
-                          allowedWriteLocations,
-                          region,
-                          accountId)
-                      .toJson())
-              .durationSeconds(storageCredentialDurationSeconds);
-      credentialsProvider.ifPresent(
-          cp -> request.overrideConfiguration(b -> b.credentialsProvider(cp)));
 
       @SuppressWarnings("resource")
       // Note: stsClientProvider returns "thin" clients that do not need 
closing
       StsClient stsClient =
           
stsClientProvider.stsClient(StsDestination.of(storageConfig.getStsEndpointUri(),
 region));
-
-      AssumeRoleResponse response = stsClient.assumeRole(request.build());
-      accessConfig.put(StorageAccessProperty.AWS_KEY_ID, 
response.credentials().accessKeyId());
-      accessConfig.put(
-          StorageAccessProperty.AWS_SECRET_KEY, 
response.credentials().secretAccessKey());
-      accessConfig.put(StorageAccessProperty.AWS_TOKEN, 
response.credentials().sessionToken());
-      Optional.ofNullable(response.credentials().expiration())
+      Credentials credentials;
+      if (storageConfig.getUserTokenSTS()) {
+        AssumeRoleWithWebIdentityRequest.Builder request =
+            AssumeRoleWithWebIdentityRequest.builder()
+                .webIdentityToken(
+                    
securityIdentity.getCredential(PolarisCredential.class).getToken())
+                .roleArn(storageConfig.getRoleARN())
+                .roleSessionName("PolarisAwsCredentialsStorageIntegration")
+                .durationSeconds(storageCredentialDurationSeconds);

Review Comment:
   from what I gather with this flow, we don't need to provide a policy string. 
Seems that the STS reads the users token and provides you with all the 
credentials you have permission for.
   
   I'm not an expert in S3 or STS so I could be way off and feel free to 
correct me if I am, but from testing with our appliance this is the way it 
seems to be. 



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

Reply via email to