Skip to content

fix: userinfo: avoid indexing by None user_id in stateless mode#46

Merged
c00kiemon5ter merged 1 commit intoIdentityPython:masterfrom
REANNZ:fix-user-info-stateless
Nov 15, 2022
Merged

fix: userinfo: avoid indexing by None user_id in stateless mode#46
c00kiemon5ter merged 1 commit intoIdentityPython:masterfrom
REANNZ:fix-user-info-stateless

Conversation

@vladimir-mencl-eresearch
Copy link
Collaborator

In stateless mode, user_id passed to get_claims_for is always None.

When no claims are available and userinfo is thus also None, user_id is used as index to self._db, but that triggers a KeyError: None.

As create_access_token populates user_info field in authz_info only of user_info is pythonically True, user_info passed here ends up being None, not empty dict {}.

As the Userinfo class does not have access to Provider.stateless, the easiest fix is to make the db lookup conditional on user_id being pythonically True - which corresponds with not being in stateltess mode.

In stateless mode, `user_id` passed to `get_claims_for` is always `None`.

When no claims are available and userinfo is thus also `None`, `user_id`
is used as index to self._db, but that triggers a `KeyError: None`.

As `create_access_token` populates `user_info` field in `authz_info`
only of `user_info` is pythonically `True`, `user_info` passed here ends
up being `None`, not empty dict `{}`.

As the `Userinfo` class does not have access to `Provider.stateless`,
the easiest fix is to make the db lookup conditional on user_id being
pythonically True - which corresponds with not being in stateltess mode.
@c00kiemon5ter c00kiemon5ter merged commit e2f7d88 into IdentityPython:master Nov 15, 2022
@vladimir-mencl-eresearch vladimir-mencl-eresearch deleted the fix-user-info-stateless branch January 13, 2023 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants