Commits

Thomas Johansson  committed eb39736

Cleanup whitespace

  • Participants
  • Parent commits cc8640e

Comments (0)

Files changed (6)

File piston/authentication/basic.py

 class HttpBasicAuthentication(object):
     """
     Basic HTTP authenticater. Synopsis:
-    
+
     Authentication handlers must implement two methods:
      - `is_authenticated`: Will be called when checking for
         authentication. Receives a `request` object, please
 
         if not auth_string:
             return False
-            
+
         try:
             (authmeth, auth) = auth_string.split(" ", 1)
 
             (username, password) = auth.split(':', 1)
         except (ValueError, binascii.Error):
             return False
-        
+
         request.user = self.auth_func(username=username, password=password) \
             or AnonymousUser()
-                
+
         return not request.user in (False, None, AnonymousUser())
-        
+
     def challenge(self):
         resp = HttpResponse("Authorization Required")
         resp['WWW-Authenticate'] = 'Basic realm="%s"' % self.realm
         self.password = password
 
         super(HttpBasicSimple, self).__init__(auth_func=self.hash, realm=realm)
-    
+
     def hash(self, username, password):
         if username == self.user.username and password == self.password:
             return self.user

File piston/authentication/oauth/__init__.py

             access_token = store.get_access_token(request, oauth_request, consumer, oauth_request['oauth_token'])
         except (InvalidConsumerError, InvalidTokenError):
             return False
-    
+
         if not verify_oauth_request(request, oauth_request, consumer, access_token):
             return False
 
         request.throttle_extra = request.consumer.key
 
         return True
-        
+
     def challenge(self):
         """
         Returns a 401 response with a small bit on
         what OAuth is, and where to learn more about it.
-        
+
         When this was written, browsers did not understand
         OAuth authentication on the browser side, and hence
         the helpful template we render. Maybe some day in the

File piston/authentication/oauth/store/__init__.py

     by the views and the authentication backend to get consumers and tokens, and
     to create tokens. The following terms are used in the documentation of the
     API:
-    
+
     Consumer:
         A class defining at minimum `key` and `secret` attributes. Both of these
         attributes must be either str or unicode.
-                
+
     Token:
         A class defining at minimum `key` and `secret` attributes. Both of these
         attributes must be either str or unicode.
-        
+
     User:
         A `django.contrib.auth.models.User` instance.
-             
+
     Any API that takes a consumer or token will be passed a Consumer or Token
     instance it itself returned at an earlier stage from one of the methods that
     take a key and return a Consumer or Token. This means if your store
     def get_consumer(self, request, oauth_request, consumer_key):
         """
         Return the Consumer for `consumer_key` or raise `InvalidConsumerError`.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `consumer_key`: The consumer key.
         """
         raise NotImplementedError
-    
+
     def get_consumer_for_request_token(self, request, oauth_request, request_token):
         """
         Return the Consumer associated with the `request_token` Token.
         `request_token`: The request token to get the consumer for.
         """
         raise NotImplementedError
-    
+
     def get_consumer_for_access_token(self, request, oauth_request, access_token):
         """
         Return the Consumer associated with the `access_token` Token.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `access_token`: The access Token to get the consumer for.
         """
         raise NotImplementedError
-        
+
     def create_request_token(self, request, oauth_request, consumer, callback):
         """
         Generate and return a Token.
     def get_request_token(self, request, oauth_request, request_token_key):
         """
         Return the Token for `request_token_key` or raise `InvalidTokenError`.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `consumer`: The Consumer that made the request.
         raise NotImplementedError
 
     def authorize_request_token(self, request, oauth_request, request_token):
-        """ 
+        """
         Authorize the `request_token` Token and return it.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `request_token`: The request token to authorize.
     def create_access_token(self, request, oauth_request, consumer, request_token):
         """
         Generate and return a Token.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `consumer`: The Consumer that made the request.
     def get_access_token(self, request, oauth_request, consumer, access_token_key):
         """
         Return the Token for `access_token_key` or raise `InvalidTokenError`.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `consumer`: The Consumer that made the request.
     def get_user_for_access_token(self, request, oauth_request, access_token):
         """
         Return the associated User for `access_token`.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `consumer`: The Consumer that made the request.
     def check_nonce(self, request, oauth_request, nonce):
         """
         Return `True` if the nonce has not yet been used, `False` otherwise.
-        
+
         `request`: The Django request object.
         `oauth_request`: The `oauth2.Request` object.
         `nonce`: The nonce to check.

File piston/authentication/oauth/store/db.py

             timestamp=oauth_request['oauth_timestamp']
         )
         token.set_callback(callback)
-        token.save()    
+        token.save()
 
         return token
 
         except Token.DoesNotExist:
             raise InvalidTokenError()
 
-    def authorize_request_token(self, request, oauth_request, request_token):    
+    def authorize_request_token(self, request, oauth_request, request_token):
         request_token.is_approved = True
         request_token.user = request.user
         request_token.verifier = oauth.generate_verifier(VERIFIER_SIZE)

File piston/authentication/oauth/utils.py

         oauth_server.verify_request(oauth_request, consumer, token)
     except oauth.Error:
         return False
-    
+
     return True
 
 

File piston/authentication/oauth/views.py

         request_token = store.get_request_token(request, oauth_request, request.REQUEST['oauth_token'])
     except InvalidTokenError:
         return HttpResponseBadRequest('Invalid request token.')
-    
+
     consumer = store.get_consumer_for_request_token(request, oauth_request, request_token)
-    
+
     if request.method == 'POST':
         form = form_class(request.POST)
         if form.is_valid() and form.cleaned_data['authorize_access']:
-            request_token = store.authorize_request_token(request, oauth_request, request_token)            
+            request_token = store.authorize_request_token(request, oauth_request, request_token)
             if request_token.callback is not None and request_token.callback != 'oob':
                 return HttpResponseRedirect('%s&%s' % (request_token.get_callback_url(), urlencode({'oauth_token': request_token.key})))
             else:
 @csrf_exempt
 def get_access_token(request):
     oauth_request = get_oauth_request(request)
+
     missing_params = require_params(oauth_request, ('oauth_token', 'oauth_verifier'))
     if missing_params is not None:
         return missing_params
-    
+
     try:
         consumer = store.get_consumer(request, oauth_request, oauth_request['oauth_consumer_key'])
         request_token = store.get_request_token(request, oauth_request, oauth_request['oauth_token'])
 
     if not verify_oauth_request(request, oauth_request, consumer, request_token):
         return HttpResponseBadRequest('Could not verify OAuth request.')
-        
+
     if oauth_request.get('oauth_verifier', None) != request_token.verifier:
         return HttpResponseBadRequest('Invalid OAuth verifier.')