Return authentication.HttpBasicAuthentication to its former pluggable state.

This commit is contained in:
Michael Richardson 2009-05-25 15:42:44 -07:00
Родитель 2e6dbc9c27
Коммит ef01d261bf
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -32,7 +32,8 @@ class HttpBasicAuthentication(object):
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):
@ -49,7 +50,8 @@ class HttpBasicAuthentication(object):
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())