From a421e2a2088f5eeb7dc396809ce48d8f4eeb1baf Mon Sep 17 00:00:00 2001 From: Brittney Exline Date: Wed, 5 Jun 2019 13:09:42 -0400 Subject: [PATCH] Fix call to is_jwt_authenticated when the request has no successful_authenticator attribute --- edx_rest_framework_extensions/__init__.py | 2 +- .../auth/jwt/authentication.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/edx_rest_framework_extensions/__init__.py b/edx_rest_framework_extensions/__init__.py index 9447fcfe..4271a256 100644 --- a/edx_rest_framework_extensions/__init__.py +++ b/edx_rest_framework_extensions/__init__.py @@ -1,3 +1,3 @@ """ edx Django REST Framework extensions. """ -__version__ = '2.3.0' # pragma: no cover +__version__ = '2.3.1' # pragma: no cover diff --git a/edx_rest_framework_extensions/auth/jwt/authentication.py b/edx_rest_framework_extensions/auth/jwt/authentication.py index 56cc7d45..bf9ae643 100644 --- a/edx_rest_framework_extensions/auth/jwt/authentication.py +++ b/edx_rest_framework_extensions/auth/jwt/authentication.py @@ -77,10 +77,13 @@ def authenticate_credentials(self, payload): def is_jwt_authenticated(request): - is_jwt_authenticated = issubclass( - type(request.successful_authenticator), - BaseJSONWebTokenAuthentication, - ) + is_jwt_authenticated = False + successful_authenticator = getattr(request, 'successful_authenticator', None) + if successful_authenticator: + is_jwt_authenticated = issubclass( + type(successful_authenticator), + BaseJSONWebTokenAuthentication + ) if is_jwt_authenticated: if not getattr(request, 'auth', None): logger.error(