Skip to content

Commit

Permalink
fix: changed a value of jwt_auth_result
Browse files Browse the repository at this point in the history
Updated one of the values of the custom attribute jwt_auth_result
from 'skipped' to 'n/a'.
  • Loading branch information
robrap committed Aug 31, 2023
1 parent a519606 commit 0d72f53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Fixed
~~~~~
* Fixes exceptional case where JwtAuthentication should not CSRF protect a request that has both a JWT token in the authorization header and a JWT cookie, since the cookie should be ignored.

Changed
~~~~~~~
* Updated one of the values of the custom attribute jwt_auth_result from 'skipped' to 'n/a'.


[8.9.1] - 2023-08-22
--------------------

Expand Down
4 changes: 2 additions & 2 deletions edx_rest_framework_extensions/auth/jwt/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def authenticate(self, request):
# .. custom_attribute_name: jwt_auth_result
# .. custom_attribute_description: The result of the JWT authenticate process,
# which can having the following values:
# 'skipped': When JWT Authentication doesn't apply.
# 'n/a': When JWT Authentication doesn't apply.
# 'success-auth-header': Successfully authenticated using the Authorization header.
# 'success-cookie': Successfully authenticated using a JWT cookie.
# 'forgiven-failure': Returns None instead of failing for JWT cookies. This handles
Expand All @@ -87,7 +87,7 @@ def authenticate(self, request):

# Unauthenticated, CSRF validation not required
if not user_and_auth:
set_custom_attribute('jwt_auth_result', 'skipped')
set_custom_attribute('jwt_auth_result', 'n/a')
return user_and_auth

# Not using JWT cookie, CSRF validation not required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_authenticate_with_bearer_token(self, mock_set_custom_attribute):
auth_header = '{token_name} {token}'.format(token_name='Bearer', token='abc123')
request = RequestFactory().get('/', HTTP_AUTHORIZATION=auth_header)
self.assertIsNone(JwtAuthentication().authenticate(request))
mock_set_custom_attribute.assert_any_call('jwt_auth_result', 'skipped')
mock_set_custom_attribute.assert_any_call('jwt_auth_result', 'n/a')

def _get_test_jwt_token(self):
""" Returns a user and jwt token """
Expand Down

0 comments on commit 0d72f53

Please sign in to comment.