Return authentication.HttpBasicAuthentication to its former pluggable state.
This commit is contained in:
Родитель
2e6dbc9c27
Коммит
ef01d261bf
|
@ -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())
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче