Skip to content

Commit

Permalink
Include user-specified signed headers (#200)
Browse files Browse the repository at this point in the history
* Support additional signed headers
  • Loading branch information
MegaWattSec authored Aug 21, 2024
1 parent 030b37d commit 22cebb0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions awscurl/awscurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22cebb0

Please sign in to comment.