Fixed infinitely recursing GlobusApp login #1002
Merged
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.
to infinitely prompt for log in.
Why was this happening?
pr-1000 added support for dependent token evaluation by means of an AuthClient which leverages the attached GlobusApp and is used for polling user consents. With this addition, users could unintentionally get themselves into an infinitely recursing login loop with the following script.
Assuming the app
"my-simple-app"
has no pre-existing tokens, the call toget_authorizer
would raise aMissingTokenError
. This error would be intercepted by the app and automatically drive a login flow to supply new tokens. Upon receiving an authorization code, the tokens would be passed through toValidatingTokenAdapater.store_token_data_by_resource_server(...)
.As a part of storing the token data, we validate that they meet both root scope requirements and dependent scope requirements. Evaluating dependent scope requirements involves that aforementioned AuthClient however polling Globus Auth for the user's current consents. This call (
AuthClient.get_consents
) would attempt to get an authorizer, which would in turn raise aMissingTokenError
(the in flight tokens have yet to be stored as they're in the middle of validation). This error would be intercepted by the app and automatically drive a login flow to supply new tokens. And the loop continues indefinitely (goto previous paragraph).To solves this problem, I removed dependent scope evaluation from token store. Dependent scopes are still evaluated on token retrieval. Root scopes are still evaluated on token storage.
📚 Documentation preview 📚: https://globus-sdk-python--1002.org.readthedocs.build/en/1002/