fix(s3): accept the log-delivery-write canned ACL (#2653)

PutBucketAcl/PutObjectAcl rejected x-amz-acl: log-delivery-write with
"Unsupported x-amz-acl value", even though it is a standard AWS canned
ACL (Terraform's aws_s3_bucket_acl / access-logging modules send it to
grant the S3 log-delivery service group permission to write access logs
into a bucket). Of the eight AWS canned ACL values, this was the only
one missing from cannedObjectAclXml's switch - the rest were already
handled.

Add the log-delivery-write case, translating it to WRITE and READ_ACP
grants for the well-known LogDelivery group URI
(http://acs.amazonaws.com/groups/s3/LogDelivery), following the same
groupGrant pattern used for public-read/public-read-write.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-08-30 14:40:35 -05:00
1 parent 6a1d86e43f
commit 2a014d2add
3 files changed
+36

No files matched your search

+1
View File
@@ -355,3 +355,4 @@ Current limitations:
- explicit ACL grant headers such as `x-amz-grant-read` and `x-amz-grant-full-control` are not modeled yet
- cross-account canned ACL variants collapse to the emulator's single synthetic owner where Floci does not model a distinct second principal
- `aws-exec-read` is accepted for compatibility, but Floci does not yet model a distinct EC2 bundle-reader grantee in `GetObjectAcl`
- `log-delivery-write` is accepted on `PutBucketAcl`/`PutObjectAcl` and grants the well-known S3 log-delivery group (`http://acs.amazonaws.com/groups/s3/LogDelivery`) `WRITE` and `READ_ACP`, matching AWS
@@ -56,6 +56,7 @@ public class S3Service implements Resettable, ResourceProvider {
private String ownerId() { return regionResolver != null ? regionResolver.getAccountId() : "000000000000"; }
private static final String DEFAULT_OWNER_DISPLAY_NAME = "floci";
private static final String AUTHENTICATED_USERS_GROUP_URI = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers";
private static final String LOG_DELIVERY_GROUP_URI = "http://acs.amazonaws.com/groups/s3/LogDelivery";
private static final String LEGACY_ACCESS_KEY_ID = "test";
private static final Set<String> SUPPORTED_SERVER_SIDE_ENCRYPTION_VALUES = Set.of("AES256", "aws:kms", "aws:kms:dsse", "aws:fsx");
private static final String SSE_C_ALGORITHM = "AES256";
@@ -2797,6 +2798,13 @@ public class S3Service implements Resettable, ResourceProvider {
case "authenticated-read" -> objectAclXml(
ownerFullControlGrant(),
groupGrant(AUTHENTICATED_USERS_GROUP_URI, "READ"));
// Standard canned ACL used by S3 server-access-logging (and Terraform's
// aws_s3_bucket_acl / access-logging modules) to grant the S3 log-delivery service
// group permission to write log objects into this bucket and read their own ACL.
case "log-delivery-write" -> objectAclXml(
ownerFullControlGrant(),
groupGrant(LOG_DELIVERY_GROUP_URI, "WRITE"),
groupGrant(LOG_DELIVERY_GROUP_URI, "READ_ACP"));
default -> throw new AwsException("InvalidArgument",
"Unsupported x-amz-acl value: " + cannedAcl, 400);
};
@@ -17,6 +17,7 @@ class S3AclIntegrationTest {
private static final String BUCKET = "acl-test-bucket";
private static final String ALL_USERS_GROUP_URI = "http://acs.amazonaws.com/groups/global/AllUsers";
private static final String AUTHENTICATED_USERS_GROUP_URI = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers";
private static final String LOG_DELIVERY_GROUP_URI = "http://acs.amazonaws.com/groups/s3/LogDelivery";
private static String multipartUploadId;
@Test
@@ -374,4 +375,30 @@ class S3AclIntegrationTest {
.body(not(containsString(ALL_USERS_GROUP_URI)))
.body(containsString("<Permission>FULL_CONTROL</Permission>"));
}
// Regression coverage for floci-3wz: PutBucketAcl rejected the "log-delivery-write" canned
// ACL, the standard value Terraform's aws_s3_bucket_acl / access-logging modules send to grant
// the S3 log-delivery service group permission to write access logs into a bucket.
@Test
@Order(17)
void putBucketAclAppliesLogDeliveryWriteCannedAcl() {
given()
.header("x-amz-acl", "log-delivery-write")
.when()
.put("/" + BUCKET + "?acl")
.then()
.statusCode(200);
given()
.when()
.get("/" + BUCKET + "?acl")
.then()
.statusCode(200)
.body(containsString(LOG_DELIVERY_GROUP_URI))
.body(containsString("<Permission>WRITE</Permission>"))
.body(containsString("<Permission>READ_ACP</Permission>"))
.body(containsString("<Permission>FULL_CONTROL</Permission>"))
.body(not(containsString(ALL_USERS_GROUP_URI)));
}
}