Skip to content

Commit

Permalink
fixup! fix test and add annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
robrap committed Apr 12, 2023
1 parent 4ca00d1 commit 6a90420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions edx_rest_framework_extensions/auth/jwt/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,14 @@ def _decode_and_verify_token(token, jwt_issuer):

# TODO (ARCH-204): verify issuer manually until it is properly configured.
token_issuer = decoded_token.get('iss')
# .. custom_attribute_name: jwt_auth_issuer
# .. custom_attribute_description: Value set to the JWT auth issuer.
set_custom_attribute('jwt_auth_issuer', token_issuer)
issuer_matched = any(issuer['ISSUER'] == token_issuer for issuer in get_jwt_issuers())
if token_issuer == jwt_issuer['ISSUER']:
# .. custom_attribute_name: jwt_auth_issuer_verification
# .. custom_attribute_description: Depending on issuer verification, the value will
# be one of: matches-first-issuer, matches-later-issuer, or no-match.
set_custom_attribute('jwt_auth_issuer_verification', 'matches-first-issuer')
elif issuer_matched:
set_custom_attribute('jwt_auth_issuer_verification', 'matches-later-issuer')
Expand Down
5 changes: 5 additions & 0 deletions edx_rest_framework_extensions/auth/jwt/tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ def test_keyset_size_monitoring(self, mock_set_custom_attribute):

assert mock_set_custom_attribute.call_args_list == [
mock.call('jwt_auth_verify_keys_count', 2),
mock.call('jwt_auth_issuer', 'test-issuer-1'),
mock.call('jwt_auth_issuer_verification', 'matches-first-issuer'),

mock.call('jwt_auth_verify_keys_count', 1),
mock.call('jwt_auth_issuer', 'test-issuer-1'),
mock.call('jwt_auth_issuer_verification', 'matches-first-issuer'),
]


Expand Down

0 comments on commit 6a90420

Please sign in to comment.