From 8c4fa0f16ac170662e113edfdc0f8d3c8863f082 Mon Sep 17 00:00:00 2001 From: Masanori Itoh Date: Thu, 7 Apr 2011 23:48:00 +0900 Subject: Blush up a bit. --- nova/auth/manager.py | 14 +++++++------- nova/utils.py | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index f1d4a1e39..c8a3a46a2 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -315,15 +315,15 @@ class AuthManager(object): LOG.debug('expected_signature: %s', expected_signature) LOG.debug('signature: %s', signature) if signature != expected_signature: - secondary = utils.get_secondary_server_string(server_string) - if secondary is not '': - secondary_signature = signer.Signer( + host_only = utils.get_host_only_server_string(server_string) + # If the given server_string contains port num, try without it. + if host_only is not '': + host_only_signature = signer.Signer( user.secret.encode()).generate(params, verb, - secondary, path) - LOG.debug('secondary_signature: %s', secondary_signature) - if signature == secondary_signature: + host_only, path) + LOG.debug('host_only_signature: %s', host_only_signature) + if signature == host_only_signature: return (user, project) - # NOTE(itoumsn): RightAWS success case. LOG.audit(_("Invalid signature for user %s"), user.name) raise exception.NotAuthorized(_('Signature does not match')) return (user, project) diff --git a/nova/utils.py b/nova/utils.py index 3e938247f..8b7cbf30c 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -716,9 +716,11 @@ def check_isinstance(obj, cls): return cls() # Ugly PyLint hack -def get_secondary_server_string(str): - """Returns host part only of the given server_string if it's a combination - of host part and port. Otherwise, return null string.""" +def get_host_only_server_string(str): + """ + Returns host part only of the given server_string if it's a combination + of host part and port. Otherwise, return null string. + """ # First of all, exclude pure IPv6 address (w/o port). if netaddr.valid_ipv6(str): -- cgit