Repository navigation
3.5.0: extra_id_token_claims callable is now invoked in stateless mode, where there is no user_db - #73
Open
alisonnRB wants to merge 1 commit into
Conversation
Collaborator
|
I ran into I believe the same issue in SATOSA (using OIDC frontend) and solved it in IdentityPython/SATOSA#506 This has been merged - but not been released yet. Would it solve the issue you're running into? |
Author
Yes, that would solve my issue! Thanks for pointing that out. |
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.
Since 3.5.0, _do_code_exchange invokes the extra_id_token_claims callable unconditionally. In 3.4.2 it was only invoked in the non-stateless branch:
3.5.0 also made user_id defined in the stateless branch (user_id = sub, provider.py:437-442). In 3.4.2 user_id was left undefined there — which shows that branch was never reachable with a callable in stateless mode.
The problem is that a callable typically consults the provider's userinfo database. That is what SATOSA's OpenIDConnectFrontend does:
And with a stateless storage SATOSA deletes the user from user_db as soon as authorize() returns, since the claims are already embedded in the authorization code:
So at the token endpoint the callable receives a user_id that is no longer in the (empty) user_db, and Userinfo.get_claims_for raises:
On top of that, in stateless mode the callable's return value is discarded anyway — extra_id_token_claims.update(extra_id_token_claims_in_code) overwrites it with the claims stored in the code.
Worth noting that pyop already handles exactly this situation correctly a few lines below, for requested_claims:
Suggested fix — keep the 3.5.0 improvement (a plain dict is now honored; in 3.4.2 it was silently dropped) but do not invoke the callable when stateless:
Alternatively, or in addition, Userinfo.get_claims_for could tolerate an unknown subject, since it is documented as a read-only wrapper over the database:
userinfo = self._db.get(user_id, {}) if user_id else {}