Conversation
The sync OpenIDMixin.parse_id_token guards "if 'id_token' not in token: return None"; the async twin did not, so the same call returns None on the sync client and raises KeyError on the async one.
Mirror the sync suite's None assertion. The guard exposed test_runtime_error_fetch_jwks_uri still calling the pre-refactor (request, token) signature (the only one of eight sites), which passed only because RuntimeError fired before the misused args were read. Corrected to (token, nonce).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenIDMixin.parse_id_tokenstarts with a guard the async version doesn't have:So the same call returns
Noneon the sync client and raisesKeyError: 'id_token'on the async one. The first commit adds it.The sync test suite already asserted the
Nonecase (test_flask/test_user_mixin.py), and the async suite never did, which is how the two drifted apart. That assertion is mirrored across.The second commit changes a test. That needs explaining.
Adding the guard means a token without an
id_tokennow returns early, beforeload_server_metadata(). That exposedtest_runtime_error_fetch_jwks_uri, which calls:The signature is
(token, nonce). That call uses the old(request, token)order, and it is the only one of eight sites that still does. The test passed because theRuntimeErrorwas raised before anything read the misplaced arguments, so the stale call never mattered. With the guard in place the request object goes in astoken, has noid_token, and returnsNonebefore the error can happen.I changed that call to
(token, nonce="n")so it matches the rest, and dropped the now-unused request object. It asserts the sameRuntimeErrorpath, now with a valid token.test_starlette/test_user_mixin.pygoes from 4 passing with one relying on that stale call to 4 passing without it. The sync suite is untouched and still passes.I ran the starlette and flask client suites. Not the django ones, which need dependencies I don't have installed.