Commits

Thomas Johansson committed cc8640e

Rename require_paramaters (don't look at the typo) to require_params and use it to check parameters in OAuthAuthentication.is_authenticated as well.

Comments (0)

Files changed (3)

piston/authentication/oauth/__init__.py

 from django.template import loader
 
 from piston.authentication.oauth.store import store, InvalidConsumerError, InvalidTokenError
-from piston.authentication.oauth.utils import get_oauth_request, verify_oauth_request
+from piston.authentication.oauth.utils import get_oauth_request, verify_oauth_request, require_params
 
 
 class OAuthAuthentication(object):
     def is_authenticated(self, request):
         oauth_request = get_oauth_request(request)
 
+        missing_params = require_params(oauth_request, ('oauth_token',))
+        if missing_params is not None:
+            return False
+
         try:
             consumer = store.get_consumer(request, oauth_request, oauth_request['oauth_consumer_key'])
             access_token = store.get_access_token(request, oauth_request, consumer, oauth_request['oauth_token'])

piston/authentication/oauth/utils.py

     return True
 
 
-def require_paramaters(oauth_request, parameters):
+def require_params(oauth_request, parameters):
     """ Ensures that the request contains all required parameters. """
     params = [
         'oauth_consumer_key',
         'oauth_nonce',
         'oauth_signature',
         'oauth_signature_method',
-        'oauth_timestamp',
+        'oauth_timestamp'
     ]
     params.extend(parameters)
 

piston/authentication/oauth/views.py

 
 from piston.authentication.oauth.forms import AuthorizeRequestTokenForm
 from piston.authentication.oauth.store import store, InvalidConsumerError, InvalidTokenError
-from piston.authentication.oauth.utils import verify_oauth_request, get_oauth_request, require_paramaters
+from piston.authentication.oauth.utils import verify_oauth_request, get_oauth_request, require_params
 
 
 @csrf_exempt
 def get_request_token(request):
     oauth_request = get_oauth_request(request)
 
-    missing_params = require_paramaters(oauth_request, ('oauth_callback',))
+    missing_params = require_params(oauth_request, ('oauth_callback',))
     if missing_params is not None:
         return missing_params
 
 @csrf_exempt
 def get_access_token(request):
     oauth_request = get_oauth_request(request)
-    missing_params = require_paramaters(oauth_request, ('oauth_token', 'oauth_verifier'))
+    missing_params = require_params(oauth_request, ('oauth_token', 'oauth_verifier'))
     if missing_params is not None:
         return missing_params