Merge lp:~fujita-tomonori-deactivatedaccount/swift/s3-auth into lp:~hudson-openstack/swift/trunk

Proposed by FUJITA Tomonori
Status: Merged
Approved by: David Goetz
Approved revision: 324
Merged at revision: 328
Proposed branch: lp:~fujita-tomonori-deactivatedaccount/swift/s3-auth
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 50 lines (+22/-3)
2 files modified
swift/common/middleware/swift3.py (+13/-3)
test/unit/common/middleware/test_swift3.py (+9/-0)
To merge this branch: bzr merge lp:~fujita-tomonori-deactivatedaccount/swift/s3-auth
Reviewer Review Type Date Requested Status
David Goetz (community) Approve
John Dickinson Approve
Review via email: mp+67530@code.launchpad.net

Description of the change

Fix swift3 authentication bug about the Date and X-Amz-Date handling.

To post a comment you must log in.
Revision history for this message
John Dickinson (notmyname) wrote :

lgtm

review: Approve
Revision history for this message
David Goetz (david-goetz) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'swift/common/middleware/swift3.py'
2--- swift/common/middleware/swift3.py 2011-05-05 20:48:22 +0000
3+++ swift/common/middleware/swift3.py 2011-07-11 11:33:29 +0000
4@@ -128,13 +128,23 @@
5 """
6 Canonicalize a request to a token that can be signed.
7 """
8+ amz_headers = {}
9+
10 buf = "%s\n%s\n%s\n" % (req.method, req.headers.get('Content-MD5', ''),
11 req.headers.get('Content-Type') or '')
12- if 'Date' in req.headers:
13- buf += "%s\n" % req.headers['Date']
14+
15 for amz_header in sorted((key.lower() for key in req.headers
16 if key.lower().startswith('x-amz-'))):
17- buf += "%s:%s\n" % (amz_header, req.headers[amz_header])
18+ amz_headers[amz_header] = req.headers[amz_header]
19+
20+ if 'x-amz-date' in amz_headers:
21+ buf += "\n"
22+ elif 'Date' in req.headers:
23+ buf += "%s\n" % req.headers['Date']
24+
25+ for k in sorted(key.lower() for key in amz_headers):
26+ buf += "%s:%s\n" % (k, amz_headers[k])
27+
28 path = req.path_qs
29 if '?' in path:
30 path, args = path.split('?', 1)
31
32=== modified file 'test/unit/common/middleware/test_swift3.py'
33--- test/unit/common/middleware/test_swift3.py 2011-05-05 21:02:08 +0000
34+++ test/unit/common/middleware/test_swift3.py 2011-07-11 11:33:29 +0000
35@@ -573,6 +573,15 @@
36 verify('7506d97002c7d2de922cc0ec34af8846', '/bucket/object',
37 {'Content-Type': None, 'X-Amz-Something': 'test'})
38
39+ verify('28f76d6162444a193b612cd6cb20e0be', '/bucket/object',
40+ {'Content-Type': None,
41+ 'X-Amz-Date': 'Mon, 11 Jul 2011 10:52:57 +0000',
42+ 'Date': 'Tue, 12 Jul 2011 10:52:57 +0000'})
43+
44+ verify('ed6971e3eca5af4ee361f05d7c272e49', '/bucket/object',
45+ {'Content-Type': None,
46+ 'Date': 'Tue, 12 Jul 2011 10:52:57 +0000'})
47+
48 req1 = Request.blank('/', headers=
49 {'Content-Type': None, 'X-Amz-Something': 'test'})
50 req2 = Request.blank('/', headers=