Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from Menda/cookie-setting
Browse files Browse the repository at this point in the history
Fix exception for JWT_AUTH_COOKIE
  • Loading branch information
Rafael Muñoz Cárdenas authored Jun 12, 2018
2 parents 1266b9d + 6503cd5 commit b3e199d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oauth2_provider_jwt/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_jwt_value(self, request):
auth_header_prefix = getattr(settings, 'JWT_AUTH_HEADER_PREFIX', 'JWT')

if not auth:
if settings.JWT_AUTH_COOKIE:
if getattr(settings, 'JWT_AUTH_COOKIE', None):
return request.COOKIES.get(settings.JWT_AUTH_COOKIE)
return None

Expand Down
10 changes: 9 additions & 1 deletion tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ class JWTAuthenticationTests(TestCase):
def setUp(self):
self.client = APIClient(enforce_csrf_checks=True)

def test_get_no_jwt_header_failing_jwt_auth(self):
def test_get_no_jwt_header(self):
"""
If there is no auth, it's part of a different layer if user needs
to be authenticated. That's why we return a positive response.
"""
response = self.client.get('/jwt/')
self.assertEqual(response.status_code, 200)

def test_get_no_jwt_token_failing_jwt_auth(self):
response = self.client.get('/jwt/', HTTP_AUTHORIZATION='JWT')
self.assertEqual(response.status_code, 401)
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
from urllib import urlencode # noqa
try:
from unittest.mock import patch
except ImportError:
Expand Down

0 comments on commit b3e199d

Please sign in to comment.