diff options
author | David Rogers <david@orlandophp.org> | 2014-03-25 17:52:35 -0400 |
---|---|---|
committer | David Rogers <david@orlandophp.org> | 2014-03-25 17:52:35 -0400 |
commit | ea106971af90556e5c682e0a367314111f7f0162 (patch) | |
tree | 5e0f601f3082fa308cde30b13743f8da8359a4c6 /oauthlib/oauth1/rfc5849/signature.py | |
parent | a66fe9800c7c7732491a213e1cacf7b82f2b1282 (diff) | |
download | oauthlib-ea106971af90556e5c682e0a367314111f7f0162.tar.gz |
Enforcing a common interface for `sign_*()` methods...
In order to support adding custom signature methods, the current signature methods -- HMAC-SHA1, RSA-SHA1, and PLAINTEXT -- need to be implemented with a common interface. In a previous attempt, I tried changing those functions directly, but there are too many dependencies on their current signatures. By shimming them instead with these thin wrappers, I can provide the common interface I need without breaking everything else in the library.
Diffstat (limited to 'oauthlib/oauth1/rfc5849/signature.py')
-rw-r--r-- | oauthlib/oauth1/rfc5849/signature.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index 77849ab..6d27318 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -407,6 +407,12 @@ def normalize_parameters(params): return '&'.join(parameter_parts) +def sign_hmac_sha1_with_client(base_string, client): + return sign_hmac_sha1(base_string, + client.client_secret, + client.resource_owner_secret + ) + def sign_hmac_sha1(base_string, client_secret, resource_owner_secret): """**HMAC-SHA1** @@ -487,6 +493,10 @@ def sign_rsa_sha1(base_string, rsa_private_key): return binascii.b2a_base64(p.sign(h))[:-1].decode('utf-8') +def sign_rsa_sha1_with_client(base_string, client): + return sign_rsa_sha1(base_string, client.rsa_key) + + def sign_plaintext(client_secret, resource_owner_secret): """Sign a request using plaintext. @@ -522,6 +532,9 @@ def sign_plaintext(client_secret, resource_owner_secret): return signature +def sign_plaintext_with_client(base_string, client): + return sign_plaintext(client.client_secret, client.resource_owner_secret) + def verify_hmac_sha1(request, client_secret=None, resource_owner_secret=None): """Verify a HMAC-SHA1 signature. |