From 32b64e5e415a53268a893209cfb15c23b510fb97 Mon Sep 17 00:00:00 2001 From: Aymen JAMAAOUI <5993228+aymenjamaaoui@users.noreply.github.com> Date: Tue, 20 Oct 2026 16:10:20 +0200 Subject: [PATCH] fix(core): pass the presigned credential of a Query POST to its handler (#6073) * fix(core): pass the presigned credential of a Query POST to its handler * test(core): sign the presigned Query POST test like a real client --- .../floci/core/common/AwsQueryController.java | 5 +++++ ...edentialsIamEnforcementIntegrationTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java index 6859c1ae0f..2277b73355 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java @@ -137,8 +137,13 @@ public class AwsQueryController { @Produces(MediaType.APPLICATION_XML) public Response dispatch( @HeaderParam("Authorization") String authorization, + @Context UriInfo uriInfo, MultivaluedMap formParams) { + return dispatch(IamEnforcementFilter.requestAuthorization(authorization, uriInfo.getQueryParameters()), + formParams); + } + private Response dispatch(String authorization, MultivaluedMap formParams) { String action = AwsQueryServiceResolver.action(formParams); if (action == null) { return xmlErrorResponse("MissingAction", diff --git a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java index 67829b0e9e..ed799c8c5b 100644 --- a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java @@ -89,6 +89,24 @@ class RedshiftGetClusterCredentialsIamEnforcementIntegrationTest { assertClusterNotFound(credentials(accessKeyId, cluster).formParam("AutoCreate", "true")); } + @Test + void getClusterCredentials_presignedWithoutJoinGroup_isDenied() { + String cluster = uniqueName("gcc-presigned"); + String user = uniqueName("gcc-presigned"); + String accessKeyId = createUser(user); + userPolicy(user, allow("redshift:GetClusterCredentials", "*")); + + assertDenied(given() + .queryParam("X-Amz-Algorithm", "AWS4-HMAC-SHA256") + .queryParam("X-Amz-Credential", accessKeyId + "/20261020/us-east-1/redshift/aws4_request") + .contentType("application/x-www-form-urlencoded") + .formParam("Action", "GetClusterCredentials") + .formParam("Version", "2012-12-01") + .formParam("ClusterIdentifier", cluster) + .formParam("DbUser", "analyst") + .formParam("DbGroups.DbGroup.1", "analysts")); + } + @Test void getClusterCredentials_withoutOptions_needsOnlyGetClusterCredentials() { String cluster = uniqueName("gcc-plain");