aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authentication.py
diff options
context:
space:
mode:
authorTom Christie2013-02-01 11:58:55 +0000
committerTom Christie2013-02-01 11:58:55 +0000
commitd9c7b1c58523d63c8118d88f44ebfdf5f35e942a (patch)
tree6efc5a04556b1800756034791ce8aed082f25d4d /rest_framework/authentication.py
parent8021bb5d5089955b171173e60dcc0968e13d29ea (diff)
parent0f0e76d8b1b7a7a28b4ce2c6d8f7ecc89e7219ff (diff)
downloaddjango-rest-framework-d9c7b1c58523d63c8118d88f44ebfdf5f35e942a.tar.bz2
Merge branch 'p3k' of https://github.com/linovia/django-rest-framework into working
Conflicts: rest_framework/authentication.py rest_framework/relations.py rest_framework/serializers.py rest_framework/settings.py rest_framework/tests/authentication.py rest_framework/tests/genericrelations.py rest_framework/tests/generics.py rest_framework/tests/relations_hyperlink.py rest_framework/tests/relations_nested.py rest_framework/tests/relations_pk.py rest_framework/tests/serializer.py
Diffstat (limited to 'rest_framework/authentication.py')
-rw-r--r--rest_framework/authentication.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py
index fc169189..76ee4bd6 100644
--- a/rest_framework/authentication.py
+++ b/rest_framework/authentication.py
@@ -3,10 +3,12 @@ Provides a set of pluggable authentication policies.
"""
from django.contrib.auth import authenticate
-from django.utils.encoding import smart_unicode, DjangoUnicodeDecodeError
+from django.utils.encoding import DjangoUnicodeDecodeError
from rest_framework import exceptions
from rest_framework.compat import CsrfViewMiddleware
+from rest_framework.compat import smart_text
from rest_framework.authtoken.models import Token
+from rest_framework.settings import api_settings
import base64
@@ -49,14 +51,15 @@ class BasicAuthentication(BaseAuthentication):
if len(auth) != 2:
raise exceptions.AuthenticationFailed('Invalid basic header')
+ encoding = api_settings.HTTP_HEADER_ENCODING
try:
- auth_parts = base64.b64decode(auth[1]).partition(':')
+ auth_parts = base64.b64decode(auth[1].encode(encoding)).partition(':')
except TypeError:
raise exceptions.AuthenticationFailed('Invalid basic header')
try:
- userid = smart_unicode(auth_parts[0])
- password = smart_unicode(auth_parts[2])
+ userid = smart_text(auth_parts[0])
+ password = smart_text(auth_parts[2])
except DjangoUnicodeDecodeError:
raise exceptions.AuthenticationFailed('Invalid basic header')