-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve control over identity_id
extraction in experimental TokenStorage
#1055
Merged
sirosen
merged 5 commits into
globus:main
from
sirosen:control-tokenstorage-identity-id-extraction
Sep 19, 2024
Merged
Improve control over identity_id
extraction in experimental TokenStorage
#1055
sirosen
merged 5 commits into
globus:main
from
sirosen:control-tokenstorage-identity-id-extraction
Sep 19, 2024
Conversation
This file contains 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
Depending on the response context (the type of OAuthTokenResponse in use) and the calling context (ValidatingTokenStorage or the base class), there are various optimal behaviors for `identity_id` determination. In order to avoid declaring any new public interface which would need support, this is defined as an internal-only hook, `TokenStorage._extract_identity_id`, and given various behaviors in different scenarios. In the typical case, it acts exactly as it used to. The following scenarios modify its behavior: - on dependent token responses, it returns None - in the ValidatingTokenStorage, it returns `ValidatingTokenStorage.identity_id` IFF the response is an OAuthRefreshTokenResponse
Define tests which ensure that all of the standard TokenStorage classes handle the variants of OAuthTokenResponse gracefully. Refresh and dependent token responses should be accepted, in spite of their data shapes not including `id_token`. In the case of refresh token data, `id_token` is absent, and in the case of dependent token data, the top-level structure is an array. As a control against these two tests, check the behavior of an authorization code grant response containing an `id_token`.
A dedicated test case stores token data twice, using a refresh token response for the second store. It verifies that under such a usage, the original identity information is preserved.
sirosen
requested review from
aaschaer,
ada-globus,
derek-globus and
kurtmckee
as code owners
September 19, 2024 03:55
derek-globus
approved these changes
Sep 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concise and clean fix!
Bug report which prompted this fix: #1050 |
sirosen
force-pushed
the
control-tokenstorage-identity-id-extraction
branch
from
September 19, 2024 19:33
6bfd4ac
to
437c00d
Compare
I fixed a little typo in the changelog; I'll go ahead with the merge as soon as CI is ✔️ |
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.
Add a private-to-the-SDK hook for controlling extraction of
identity_id
, and use that hook to implement the appropriate override forValidatingTokenStorage
to use its ownidentity_id
value when handling refresh tokens.Additionally, fix
OAuthDependentTokenResponse
handling in the general case, and add tests which validate these behaviors.These changes fix a bug in the handling of token refreshes under
GlobusApp
.📚 Documentation preview 📚: https://globus-sdk-python--1055.org.readthedocs.build/en/1055/