Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oauth issue with HMAC and unicode #289

Closed
BugVito opened this issue Jul 22, 2014 · 2 comments
Closed

Oauth issue with HMAC and unicode #289

BugVito opened this issue Jul 22, 2014 · 2 comments

Comments

@BugVito
Copy link

BugVito commented Jul 22, 2014

While testing out the OAuth1 functionality, I bumped into the following:


2014-07-22 09:50:35,460 [ERROR] django.request: Internal Server Error: /xAPI/OAuth/initiate
Traceback (most recent call last):
  File "/home/adllrs/LRS/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/adllrs/LRS/ADL_LRS/oauth_provider/views.py", line 41, in request_token
    token = oauth_server.fetch_request_token(oauth_request)
  File "/home/adllrs/LRS/ADL_LRS/oauth_provider/oauth/oauth.py", line 405, in fetch_request_token
    self._check_signature(oauth_request, consumer, None)
  File "/home/adllrs/LRS/ADL_LRS/oauth_provider/oauth/oauth.py", line 505, in _check_signature
    token, signature)
  File "/home/adllrs/LRS/ADL_LRS/oauth_provider/oauth/oauth.py", line 601, in check_signature
    built = self.build_signature(oauth_request, consumer, token)
  File "/home/adllrs/LRS/ADL_LRS/oauth_provider/oauth/oauth.py", line 633, in build_signature
    hashed = hmac.new(key, raw, sha)
  File "/usr/lib/python2.7/hmac.py", line 133, in new
    return HMAC(key, msg, digestmod)
  File "/usr/lib/python2.7/hmac.py", line 72, in __init__
    self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode

From what I can find out, HMAC does not accept unicode for the key, but for reasons I haven't figured out yet, is receiving a unicode key.
My temporary solution is to edit ADL_LRS/oauth_provider/oauth/oauth.py
line 633, from:

hashed = hmac.new(key, raw, sha)

to:

hashed = hmac.new(str(key), raw, sha)

My envorinment:

  • Unbuntu 14.04 LTS server 64bit
  • Python 2.7.6
@ljwolford
Copy link
Contributor

Do you have any code/process to duplicate the issue? I cannot duplicate it. There is an open pull request now that uses an updated version of the oauth library so hopefully it will handle this.

@BugVito
Copy link
Author

BugVito commented Aug 26, 2014

Unfortunately I have no procedure. A basic Ubuntu 14.04 LTS install, and that's pretty much it.
I can see tests in the merge request, and it is quite possible that my current odd setup is the issue. The tests are good enough for me, and my current easy fix-of-fortune is doing the job for the moment.
I will create a new bug, with documentation, if the problem reoccurs on a new setup.

@BugVito BugVito closed this as completed Aug 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants