Created
July 12, 2011 19:40
-
-
Save andymckay/1078801 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/apps/api/authentication.py b/apps/api/authentication.py | |
index 70f6610..6b8bd6d 100644 | |
--- a/apps/api/authentication.py | |
+++ b/apps/api/authentication.py | |
@@ -1,3 +1,5 @@ | |
+from functools import partial | |
+ | |
import jingo | |
from piston.authentication.oauth import OAuthAuthentication, views | |
@@ -20,6 +22,10 @@ class AMOOAuthAuthentication(OAuthAuthentication): | |
if request.user and request.user.is_authenticated(): | |
return True | |
+ # To avoid patching django-piston, use a partial to cope with | |
+ # piston not sending in request when called later. | |
+ self.challenge = partial(self._challenge, request=request) | |
+ | |
# Authenticate the user using Piston, rv will be True or False | |
# depending upon how it went. | |
rv = super(AMOOAuthAuthentication, self).is_authenticated(request) | |
@@ -36,7 +42,7 @@ class AMOOAuthAuthentication(OAuthAuthentication): | |
return rv | |
- def challenge(self, request): | |
+ def _challenge(self, request): | |
response = jingo.render(request, 'piston/oauth/challenge.html', status=401) | |
response['WWW-Authenticate'] = 'OAuth realm="API"' | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment