Commits

Michael Richardson committed 3c423be

Return authentication.HttpBasicAuthentication to its former pluggable state.

Comments (0)

Files changed (1)

piston/authentication.py

         This will usually be a `HttpResponse` object with
         some kind of challenge headers and 401 code on it.
     """
-    def __init__(self, realm='API'):
+    def __init__(self, auth_func=authenticate, realm='API'):
+        self.auth_func = auth_func
         self.realm = realm
 
     def is_authenticated(self, request):
         auth = auth.strip().decode('base64')
         (username, password) = auth.split(':', 1)
         
-        request.user = authenticate(username=username, password=password) or AnonymousUser()
+        request.user = self.auth_func(username=username, password=password) \
+            or AnonymousUser()
         
         return not request.user in (False, None, AnonymousUser())