From 3e2bb934026b69aff560afd146da5968d17d0d8e Mon Sep 17 00:00:00 2001 From: Mark Davidoff Date: Thu, 13 Dec 2018 12:23:36 -0800 Subject: [PATCH] Need to pass root request object to authenticate, not DRF's Request class --- rest_framework/authentication.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index 25150d525..74e0963ae 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -12,7 +12,7 @@ from django.utils.six import text_type from django.utils.translation import ugettext_lazy as _ from rest_framework import HTTP_HEADER_ENCODING, exceptions - +from rest_framework.request import Request as DRFRequest def get_authorization_header(request): """ @@ -94,6 +94,8 @@ class BasicAuthentication(BaseAuthentication): get_user_model().USERNAME_FIELD: userid, 'password': password } + if request and isinstance(request, DRFRequest): + request = request._request user = authenticate(request=request, **credentials) if user is None: