Skip to content

Instantly share code, notes, and snippets.

@VikParuchuri
Created October 2, 2012 16:21
Show Gist options
  • Save VikParuchuri/3820628 to your computer and use it in GitHub Desktop.
Save VikParuchuri/3820628 to your computer and use it in GitHub Desktop.
New QuerySignatureV1AuthHandler
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())
@davclark
Copy link

This is incredibly central, and should be merged into a tagged release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment