summaryrefslogtreecommitdiffstats
path: root/nova/auth
diff options
context:
space:
mode:
authorBrendan Maguire <B_Maguire@Dell.com>2011-09-13 11:57:33 +0100
committerBrendan Maguire <B_Maguire@Dell.com>2011-09-28 09:38:17 +0100
commit07cf091f9f3b6412d3aed4a1a49d2b0d0bb95247 (patch)
tree5fdbbd925671e263740e7bb180d0d23a52a69765 /nova/auth
parenta2646129bc9dbd9dec57bdde7f510e0ea7bbddea (diff)
downloadnova-07cf091f9f3b6412d3aed4a1a49d2b0d0bb95247.tar.gz
nova-07cf091f9f3b6412d3aed4a1a49d2b0d0bb95247.tar.xz
nova-07cf091f9f3b6412d3aed4a1a49d2b0d0bb95247.zip
Signer no longer fails if hashlib.sha256 is not available. test_signer unit test added.
Change-Id: I7cea9900c2ccabc30800a167f127ada8386a724b
Diffstat (limited to 'nova/auth')
-rw-r--r--nova/auth/signer.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/auth/signer.py b/nova/auth/signer.py
index 744e315d4..c0468021b 100644
--- a/nova/auth/signer.py
+++ b/nova/auth/signer.py
@@ -67,6 +67,8 @@ class Signer(object):
self.hmac = hmac.new(secret_key, digestmod=hashlib.sha1)
if hashlib.sha256:
self.hmac_256 = hmac.new(secret_key, digestmod=hashlib.sha256)
+ else:
+ self.hmac_256 = None
def s3_authorization(self, headers, verb, path):
"""Generate S3 authorization string."""
@@ -77,7 +79,12 @@ class Signer(object):
return b64_hmac
def generate(self, params, verb, server_string, path):
- """Generate auth string according to what SignatureVersion is given."""
+ """Generate auth string according to what SignatureVersion is given.
+
+ The signature method defaults to SHA256 if available, or falls back to
+ SHA1 if not.
+
+ """
if params['SignatureVersion'] == '0':
return self._calc_signature_0(params)
if params['SignatureVersion'] == '1':
@@ -150,6 +157,5 @@ class Signer(object):
if __name__ == '__main__':
- print Signer('foo').generate({'SignatureMethod': 'HmacSHA256',
- 'SignatureVersion': '2'},
- 'get', 'server', '/foo')
+ print Signer('foo').generate({'SignatureVersion': '2'}, 'get', 'server',
+ '/foo')