pavibhai commented on code in PR #1424:
URL: https://github.com/apache/polaris/pull/1424#discussion_r2237169813


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsCredentialsStorageIntegration.java:
##########
@@ -198,7 +206,32 @@ private IamPolicy policyString(
     bucketGetLocationStatementBuilder
         .values()
         .forEach(statementBuilder -> 
policyBuilder.addStatement(statementBuilder.build()));
-    return 
policyBuilder.addStatement(allowGetObjectStatementBuilder.build()).build();
+
+    policyBuilder.addStatement(allowGetObjectStatementBuilder.build());
+
+    if (isKMSSupported(callContext)) {
+      policyBuilder.addStatement(
+          IamStatement.builder()
+              .effect(IamEffect.ALLOW)
+              .addAction("kms:GenerateDataKey")
+              .addAction("kms:Decrypt")
+              .addAction("kms:DescribeKey")
+              .addResource("arn:aws:kms:" + region + ":" + awsAccountId + 
":key/*")
+              .addCondition(IamConditionOperator.STRING_EQUALS, 
"aws:PrincipalArn", roleARN)
+              .addCondition(
+                  IamConditionOperator.STRING_LIKE,
+                  "kms:EncryptionContext:aws:s3:arn",
+                  getArnPrefixFor(roleARN)
+                      + StorageUtil.getBucket(
+                          
URI.create(awsStorageConfigurationInfo.getAllowedLocations().get(0)))

Review Comment:
   yeah I agree with @flyrain this should be in the context of the allowed read 
and write paths, translating to read and write permissions on KMS with the 
restrictions.
   
   With respect to encryption context, we should also [support bucket 
keys](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#encryption-context)
 in which case the encryption context will be at the bucket level.



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