Skip to content

Commit

Permalink
Fix bug related to use of DEFAULT_JWT_SUPPORTED_VERSION.
Browse files Browse the repository at this point in the history
  • Loading branch information
douglashall authored and Douglas Hall committed Jun 20, 2018
1 parent cf57da2 commit f1e51a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion edx_rest_framework_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" edx Django REST Framework extensions. """

__version__ = '1.3.0' # pragma: no cover
__version__ = '1.4.0' # pragma: no cover
5 changes: 3 additions & 2 deletions edx_rest_framework_extensions/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def generate_jwt_payload(user, scopes=None, filters=None, version='1.0.0'):
'email': user.email,
'iat': now,
'exp': now + ttl,
'version': version,
}
if version:
payload['version'] = version
if scopes:
payload['scopes'] = scopes
if filters:
Expand Down Expand Up @@ -153,7 +154,7 @@ def test_decode_supported_jwt_version_not_specified(self):
token = generate_jwt_token(self.payload)
self.assertDictEqual(utils.jwt_decode_handler(token), self.payload)

@ddt.data('0.5.0', '1.0.0', '1.0.5', '1.5.0', '1.5.5')
@ddt.data(None, '0.5.0', '1.0.0', '1.0.5', '1.5.0', '1.5.5')
def test_decode_supported_jwt_version(self, jwt_version):
"""
Verifies the JWT is decoded successfully when the JWT_SUPPORTED_VERSION setting is not specified.
Expand Down
2 changes: 1 addition & 1 deletion edx_rest_framework_extensions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def verify_jwt_version(decoded_token):
settings.JWT_AUTH.get('JWT_SUPPORTED_VERSION', DEFAULT_JWT_SUPPORTED_VERSION)
)
jwt_version = semantic_version.Version(
decoded_token.get('version', supported_version)
decoded_token.get('version', str(supported_version))
)
if jwt_version.major > supported_version.major:
logger.info('Token decode failed due to unsupported JWT version number [%s]', str(jwt_version))
Expand Down

0 comments on commit f1e51a0

Please sign in to comment.