Skip to content

Commit

Permalink
chore: add additional logging to JWT auth middleware authenticate_cre…
Browse files Browse the repository at this point in the history
…dentials (#292)
  • Loading branch information
adamstankiewicz authored Jan 18, 2023
1 parent 3ae94bb commit b5ed5c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Change Log
Unreleased
----------

[8.4.1] - 2022-12-18
--------------------

Added
~~~~~

* Additional logging in `authenticate_credentials` within the JWT authentication middleware for debugging purposes.

[8.4.0] - 2022-12-16
--------------------

Expand Down
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__ = '8.4.0' # pragma: no cover
__version__ = '8.4.1' # pragma: no cover
2 changes: 1 addition & 1 deletion edx_rest_framework_extensions/auth/jwt/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def authenticate_credentials(self, payload):
if attributes_updated:
user.save()
except Exception as authentication_error:
msg = 'User retrieval failed.'
msg = f'[edx-drf-extensions] User retrieval failed for username {username}.'
logger.exception(msg)
raise exceptions.AuthenticationFailed(msg) from authentication_error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_authenticate_credentials_user_retrieval_failed(self):
JwtAuthentication().authenticate_credentials,
{'username': 'test', 'email': 'test@example.com'}
)
logger.assert_called_with('User retrieval failed.')
logger.assert_called_with('[edx-drf-extensions] User retrieval failed for username test.')

def test_authenticate_credentials_no_usernames(self):
""" Verify an AuthenticationFailed exception is raised if the payload contains no username claim. """
Expand Down

0 comments on commit b5ed5c8

Please sign in to comment.