Created
October 2, 2012 16:21
-
-
Save VikParuchuri/3820628 to your computer and use it in GitHub Desktop.
New QuerySignatureV1AuthHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuerySignatureV1AuthHandler(QuerySignatureHelper, AuthHandler): | |
""" | |
Provides Query Signature V1 Authentication. | |
""" | |
SignatureVersion = 1 | |
capability = ['sign-v1', 'mturk'] | |
def _calc_signature(self, params, *args): | |
boto.log.debug('using _calc_signature_1') | |
hmac1 = self._get_hmac() | |
keys = params.keys() | |
keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower())) | |
pairs = [] | |
sign_vals=[] | |
for key in keys: | |
#hmac1.update(key) | |
val = boto.utils.get_utf8_value(params[key]) | |
#hmac1.update(val) | |
pairs.append(key + '=' + urllib.quote(val)) | |
sign_vals.append(key+val) | |
qs = '&'.join(pairs) | |
signstring="".join(sign_vals) | |
new_h=hmac.new(self._provider.secret_key,signstring,sha) | |
boto.log.debug('signstring:\n%s' % signstring) | |
return (qs, base64.encodestring(new_h.digest()).strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is incredibly central, and should be merged into a tagged release!