Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 0126a6e

Browse files
committed
Fix authentication changes in Python 2
1 parent fc3d71e commit 0126a6e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rest_framework_jwt/authentication.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import jwt
2+
23
from rest_framework import exceptions
3-
from rest_framework_jwt.settings import api_settings
4+
from rest_framework.compat import smart_text
45
from rest_framework.authentication import (BaseAuthentication,
56
get_authorization_header)
67

8+
from rest_framework_jwt.settings import api_settings
9+
710
try:
811
from django.contrib.auth import get_user_model
912
except ImportError: # Django < 1.5
@@ -33,9 +36,9 @@ def authenticate(self, request):
3336
supplied using JWT-based authentication. Otherwise returns `None`.
3437
"""
3538
auth = get_authorization_header(request).split()
36-
jwt_auth_header_prefix = api_settings.JWT_AUTH_HEADER_PREFIX
39+
auth_header_prefix = api_settings.JWT_AUTH_HEADER_PREFIX.lower()
3740

38-
if not auth or auth[0].lower() != jwt_auth_header_prefix.lower():
41+
if not auth or smart_text(auth[0].lower()) != auth_header_prefix:
3942
return None
4043

4144
if len(auth) == 1:

0 commit comments

Comments
 (0)