From 22cebb05f1a1bf6280933db30943a1ca54cab1b9 Mon Sep 17 00:00:00 2001 From: "Dustin W." Date: Wed, 21 Aug 2024 03:16:50 +0000 Subject: [PATCH] Include user-specified signed headers (#200) * Support additional signed headers --- awscurl/awscurl.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awscurl/awscurl.py b/awscurl/awscurl.py index cdb275b..453fccf 100755 --- a/awscurl/awscurl.py +++ b/awscurl/awscurl.py @@ -215,6 +215,13 @@ def task_1_create_a_canonical_request( if security_token: signed_headers += ';x-amz-security-token' + # Step 5.5: Add custom signed headers into the canonical_headers and signed_headers lists. + # Header names must be lowercase, values trimmed, and sorted in ASCII order. + for header, value in sorted(headers.items()): + if "x-amz-" in header.lower(): + canonical_headers += (header.lower() + ':' + value.strip() + '\n') + signed_headers += (';' + header.lower().split(':')[0]) + # Step 6: Create payload hash (hash of the request body content). For GET # requests, the payload is an empty string (""). payload_hash = sha256_hash_for_binary_data(data) if data_binary else sha256_hash(data)