From 55ebda9d65b0c4543f45bbf1eac0b4f2ded1bcdf Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 23 Feb 2011 11:55:49 +0900 Subject: [PATCH 1/3] s3api: use boto to get canonical string for signature Replace the homegrown function to get a canonical string for signature. --- swift/common/middleware/swift3.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/swift/common/middleware/swift3.py b/swift/common/middleware/swift3.py index 26626375bc..e071624399 100644 --- a/swift/common/middleware/swift3.py +++ b/swift/common/middleware/swift3.py @@ -55,6 +55,7 @@ import rfc822 import hmac import base64 import errno +import boto.utils from xml.sax.saxutils import escape as xml_escape import cgi @@ -378,31 +379,18 @@ class Swift3Middleware(object): return ServiceController, d def get_account_info(self, env, req): - if req.headers.get("content-md5"): - md5 = req.headers.get("content-md5") - else: - md5 = "" - - if req.headers.get("content-type"): - content_type = req.headers.get("content-type") - else: - content_type = "" - - if req.headers.get("date"): - date = req.headers.get("date") - else: - date = "" - - h = req.method + "\n" + md5 + "\n" + content_type + "\n" + date + "\n" - for header in req.headers: - if header.startswith("X-Amz-"): - h += header.lower() + ":" + str(req.headers[header]) + "\n" - h += req.path try: account, user, _junk = \ req.headers['Authorization'].split(' ')[-1].split(':') except Exception: return None, None + + headers = {} + for key in req.headers: + if type(req.headers[key]) == str: + headers[key] = req.headers[key] + + h = boto.utils.canonical_string(req.method, req.path_qs, headers) token = base64.urlsafe_b64encode(h) return '%s:%s' % (account, user), token From 14d0784c0139d8eaa4918af57af4a175f61fafc3 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 23 Feb 2011 11:57:31 +0900 Subject: [PATCH 2/3] update docs about python-boto dependency --- doc/source/development_saio.rst | 2 +- doc/source/getting_started.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index 38c0475975..10b89e9051 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -31,7 +31,7 @@ Installing dependencies and the core code #. `apt-get install curl gcc bzr memcached python-configobj python-coverage python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3 xfsprogs python-webob python-eventlet - python-greenlet python-pastedeploy python-netifaces` + python-greenlet python-pastedeploy python-netifaces python-boto` #. Install anything else you want, like screen, ssh, vim, etc. #. Next, choose either :ref:`partition-section` or :ref:`loopback-section`. diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst index 219adfb462..9f24970063 100644 --- a/doc/source/getting_started.rst +++ b/doc/source/getting_started.rst @@ -22,6 +22,7 @@ And the following python libraries: * Nose * Sphinx * netifaces +* boto ----------- Development From 8dafefbb660139d28b37be6750fc494ea9f1c6e9 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 1 Mar 2011 20:50:28 +0900 Subject: [PATCH 3/3] s3api: move boto dependency descriptions to swift3.py --- doc/source/development_saio.rst | 2 +- doc/source/getting_started.rst | 1 - swift/common/middleware/swift3.py | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index 10b89e9051..38c0475975 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -31,7 +31,7 @@ Installing dependencies and the core code #. `apt-get install curl gcc bzr memcached python-configobj python-coverage python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3 xfsprogs python-webob python-eventlet - python-greenlet python-pastedeploy python-netifaces python-boto` + python-greenlet python-pastedeploy python-netifaces` #. Install anything else you want, like screen, ssh, vim, etc. #. Next, choose either :ref:`partition-section` or :ref:`loopback-section`. diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst index 9f24970063..219adfb462 100644 --- a/doc/source/getting_started.rst +++ b/doc/source/getting_started.rst @@ -22,7 +22,6 @@ And the following python libraries: * Nose * Sphinx * netifaces -* boto ----------- Development diff --git a/swift/common/middleware/swift3.py b/swift/common/middleware/swift3.py index e071624399..423b0123be 100644 --- a/swift/common/middleware/swift3.py +++ b/swift/common/middleware/swift3.py @@ -16,6 +16,9 @@ """ The swift3 middleware will emulate the S3 REST api on top of swift. +The boto python library is necessary to use this middleware (install +the python-boto package if you use Ubuntu). + The following opperations are currently supported: * GET Service