From 37a7f3b16507fa69e4fb8eb5614ca01c7341f47c Mon Sep 17 00:00:00 2001 From: Dengke Date: Wed, 26 Feb 2025 09:47:29 -0800 Subject: [PATCH 1/3] fix the signing config --- s3transfer/crt.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/s3transfer/crt.py b/s3transfer/crt.py index 37b041d8..aaaf86e1 100644 --- a/s3transfer/crt.py +++ b/s3transfer/crt.py @@ -895,14 +895,22 @@ def _default_get_make_request_args( ) and accesspoint_arn_details['region'] == "": # Configure our region to `*` to propogate in `x-amz-region-set` # for multi-region support in MRAP accesspoints. + # use_double_uri_encode and should_normalize_uri_path are defaulted to be True + # But SDK already encoded the URI, and it's for S3, so set both to False make_request_args['signing_config'] = AwsSigningConfig( algorithm=AwsSigningAlgorithm.V4_ASYMMETRIC, region="*", + use_double_uri_encode=False, + should_normalize_uri_path=False ) call_args.bucket = accesspoint_arn_details['resource_name'] elif is_s3express_bucket(call_args.bucket): + # use_double_uri_encode and should_normalize_uri_path are defaulted to be True + # But SDK already encoded the URI, and it's for S3, so set both to False make_request_args['signing_config'] = AwsSigningConfig( - algorithm=AwsSigningAlgorithm.V4_S3EXPRESS + algorithm=AwsSigningAlgorithm.V4_S3EXPRESS, + use_double_uri_encode=False, + should_normalize_uri_path=False ) return make_request_args From 3880d0364a6392b5a360269b1982aa90b78e8e1b Mon Sep 17 00:00:00 2001 From: Dengke Date: Wed, 26 Feb 2025 10:30:16 -0800 Subject: [PATCH 2/3] add test and lint --- s3transfer/crt.py | 4 ++-- tests/functional/test_crt.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/s3transfer/crt.py b/s3transfer/crt.py index aaaf86e1..b11c3682 100644 --- a/s3transfer/crt.py +++ b/s3transfer/crt.py @@ -901,7 +901,7 @@ def _default_get_make_request_args( algorithm=AwsSigningAlgorithm.V4_ASYMMETRIC, region="*", use_double_uri_encode=False, - should_normalize_uri_path=False + should_normalize_uri_path=False, ) call_args.bucket = accesspoint_arn_details['resource_name'] elif is_s3express_bucket(call_args.bucket): @@ -910,7 +910,7 @@ def _default_get_make_request_args( make_request_args['signing_config'] = AwsSigningConfig( algorithm=AwsSigningAlgorithm.V4_S3EXPRESS, use_double_uri_encode=False, - should_normalize_uri_path=False + should_normalize_uri_path=False, ) return make_request_args diff --git a/tests/functional/test_crt.py b/tests/functional/test_crt.py index a80cd82e..7b845729 100644 --- a/tests/functional/test_crt.py +++ b/tests/functional/test_crt.py @@ -163,6 +163,12 @@ def _assert_expected_s3express_request( make_request_kwargs['signing_config'].algorithm, awscrt.auth.AwsSigningAlgorithm.V4_S3EXPRESS, ) + self.assertFalse( + make_request_kwargs['signing_config'].use_double_uri_encode, + ) + self.assertFalse( + make_request_kwargs['signing_config'].should_normalize_uri_path, + ) def _assert_expected_mrap_request( self, make_request_kwargs, expected_http_method='GET' @@ -179,6 +185,12 @@ def _assert_expected_mrap_request( awscrt.auth.AwsSigningAlgorithm.V4_ASYMMETRIC, ) self.assertEqual(make_request_kwargs['signing_config'].region, "*") + self.assertFalse( + make_request_kwargs['signing_config'].use_double_uri_encode, + ) + self.assertFalse( + make_request_kwargs['signing_config'].should_normalize_uri_path, + ) def _assert_subscribers_called(self, expected_future=None): self.assertTrue(self.record_subscriber.on_queued_called) From 01c1b563e476a62e05eea55502f6ae4e5cb1114b Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Wed, 26 Feb 2025 11:42:59 -0700 Subject: [PATCH 3/3] Add changelog --- .changes/next-release/bugfix-awscrt-11663.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/next-release/bugfix-awscrt-11663.json diff --git a/.changes/next-release/bugfix-awscrt-11663.json b/.changes/next-release/bugfix-awscrt-11663.json new file mode 100644 index 00000000..7bcbd37d --- /dev/null +++ b/.changes/next-release/bugfix-awscrt-11663.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "``awscrt``", + "description": "Fix urlencoding issues for request signing with the awscrt." +}