Light, fluffy, and always free - The AWS Local Emulator alternative
fix(core): pass the presigned credential of a Query POST to its handler (#6073)
Aymen JAMAAOUI32b64e5e415a
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.javaindex 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<String, String> formParams) {+ return dispatch(IamEnforcementFilter.requestAuthorization(authorization, uriInfo.getQueryParameters()),+ formParams);+ }+ private Response dispatch(String authorization, MultivaluedMap<String, String> 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.javaindex 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"));+ }+@Testvoid getClusterCredentials_withoutOptions_needsOnlyGetClusterCredentials() {String cluster = uniqueName("gcc-plain");