summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Knapp <kyleknap@amazon.com>2014-09-19 13:08:42 -0700
committerKyle Knapp <kyleknap@amazon.com>2014-09-19 13:08:42 -0700
commit8853e8ef2d4233132767671730c542d4dcbd2506 (patch)
tree3207f830aff6a0bcfcbaff0edafed3b7bbca28e9
parent8c6ea21f25895c5c62eabae89d2be622f0e5c8e0 (diff)
parent6030ef859c93c6472443e0221bfcdc9c8a3466ce (diff)
downloadboto-8853e8ef2d4233132767671730c542d4dcbd2506.tar.gz
Merge pull request #2604 from kyleknap/bjs-s3
Fix bug where sigv4 custom metadata headers were presigned incorrectly.
-rw-r--r--boto/auth.py4
-rw-r--r--tests/unit/s3/test_connection.py20
2 files changed, 24 insertions, 0 deletions
diff --git a/boto/auth.py b/boto/auth.py
index df8dcccd..0d42dd52 100644
--- a/boto/auth.py
+++ b/boto/auth.py
@@ -705,6 +705,10 @@ class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler):
if self._provider.security_token:
params['X-Amz-Security-Token'] = self._provider.security_token
+ headers_to_sign = self.headers_to_sign(req)
+ l = sorted(['%s' % n.lower().strip() for n in headers_to_sign])
+ params['X-Amz-SignedHeaders'] = ';'.join(l)
+
req.params.update(params)
cr = self.canonical_request(req)
diff --git a/tests/unit/s3/test_connection.py b/tests/unit/s3/test_connection.py
index 35ebce97..5839a6a2 100644
--- a/tests/unit/s3/test_connection.py
+++ b/tests/unit/s3/test_connection.py
@@ -135,6 +135,26 @@ class TestSigV4Presigned(MockServiceWithConfigTestCase):
self.assertIn('VersionId=2', url)
self.assertIn('X-Amz-Security-Token=token', url)
+ def test_sigv4_presign_headers(self):
+ self.config = {
+ 's3': {
+ 'use-sigv4': True,
+ }
+ }
+
+ conn = self.connection_class(
+ aws_access_key_id='less',
+ aws_secret_access_key='more',
+ host='s3.amazonaws.com'
+ )
+
+ headers = {'x-amz-meta-key': 'val'}
+ url = conn.generate_url_sigv4(86400, 'GET', bucket='examplebucket',
+ key='test.txt', headers=headers)
+
+ self.assertIn('host', url)
+ self.assertIn('x-amz-meta-key', url)
+
class TestUnicodeCallingFormat(AWSMockServiceTestCase):
connection_class = S3Connection