Skip to content

Commit

Permalink
Fix a bug in presigned URL, resulted in invalid payload. (#423)
Browse files Browse the repository at this point in the history
This was experienced and reported by @elcolie.
  • Loading branch information
harshavardhana authored Nov 22, 2016
1 parent d7c4b1a commit 31e8a35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,8 @@ def copy_object(self, bucket_name, object_name, object_source,

headers = {}
if conditions:
headers = conditions
for k in conditions.keys():
headers[k] = conditions[k]
headers['X-Amz-Copy-Source'] = urlencode(object_source)

method = 'PUT'
Expand Down
6 changes: 3 additions & 3 deletions minio/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
_SIGN_V4_ALGORITHM = 'AWS4-HMAC-SHA256'

# Hardcoded S3 header value for X-Amz-Content-Sha256
_UNSIGNED_PAYLOAD = b'UNSIGNED-PAYLOAD'
_UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'

def post_presign_signature(date, region, secret_key, policy_str):
"""
Expand Down Expand Up @@ -198,7 +198,7 @@ def sign_v4(method, url, region, headers=None, access_key=None,

date = datetime.utcnow()
headers['X-Amz-Date'] = date.strftime("%Y%m%dT%H%M%SZ")
headers['X-Amz-Content-Sha256'] = content_sha256.decode('ascii')
headers['X-Amz-Content-Sha256'] = content_sha256

headers_to_sign = dict(headers)

Expand All @@ -209,7 +209,7 @@ def sign_v4(method, url, region, headers=None, access_key=None,
canonical_req = generate_canonical_request(method,
parsed_url,
headers_to_sign,
content_sha256.decode('ascii'))
content_sha256)
string_to_sign = generate_string_to_sign(date, region,
canonical_req)
signing_key = generate_signing_key(date, region, secret_key)
Expand Down

0 comments on commit 31e8a35

Please sign in to comment.