Ideally we would set `verify_iss' to True on this line:
|
'verify_iss': False, # TODO (ARCH-204): manually verify until issuer is configured correctly. |
This would be in place of the manual verification done across all the JWT_ISSUERS, using this code (which could be removed):
|
# 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') |
|
else: |
|
set_custom_attribute('jwt_auth_issuer_verification', 'no-match') |
|
logger.info('Token decode failed due to mismatched issuer [%s]', token_issuer) |
|
raise jwt.InvalidTokenError('%s is not a valid issuer.' % token_issuer) |
Note: this code could be removed once monitoring proves out that jwt_auth_issuer_verification always has a value of matches-first-issuer across services, especially including ecommerce and discovery, which still have add settings.
Note: Last discussed, it seemed to make sense the JWT_ISSUERS would remain a list, just in case we want to expand again in the future for rotating or moving.
Ideally we would set `verify_iss' to True on this line:
edx-drf-extensions/edx_rest_framework_extensions/auth/jwt/decoder.py
Line 261 in ae7416f
This would be in place of the manual verification done across all the JWT_ISSUERS, using this code (which could be removed):
edx-drf-extensions/edx_rest_framework_extensions/auth/jwt/decoder.py
Lines 275 to 291 in ae7416f
Note: this code could be removed once monitoring proves out that
jwt_auth_issuer_verificationalways has a value ofmatches-first-issueracross services, especially including ecommerce and discovery, which still have add settings.Note: Last discussed, it seemed to make sense the JWT_ISSUERS would remain a list, just in case we want to expand again in the future for rotating or moving.