Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit da554e0

Browse files
committed
Fix token exchange claims on userinfo endpoint
1 parent 16aac13 commit da554e0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/oidcop/oidc/userinfo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ def process_request(self, request=None, **kwargs):
141141
# if "offline_access" in session["authn_req"]["scope"]:
142142
# pass
143143

144+
_cntxt = self.server_get("endpoint_context")
144145
if allowed:
145-
_claims = _grant.claims.get("userinfo")
146-
info = self.server_get("endpoint_context").claims_interface.get_user_claims(
147-
user_id=_session_info["user_id"], claims_restriction=_claims
146+
_claims_restriction = _cntxt.claims_interface.get_claims(
147+
_session_info["session_id"], scopes=token.scope, claims_release_point="userinfo"
148148
)
149+
info = _cntxt.claims_interface.get_user_claims(_session_info["user_id"],
150+
claims_restriction=_claims_restriction)
149151
info["sub"] = _grant.sub
150152
if _grant.add_acr_value("userinfo"):
151153
info["acr"] = _grant.authentication_event["authn_info"]

tests/test_26_oidc_userinfo_endpoint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ def test_scopes_to_claims(self):
322322

323323
session_id = self._create_session(_auth_req)
324324
grant = self.session_manager[session_id]
325+
grant.scope = _auth_req["scope"]
325326
access_token = self._mint_token("access_token", grant, session_id)
326327

327328
self.endpoint.kwargs["add_claims_by_scope"] = True
@@ -366,6 +367,7 @@ def test_scopes_to_claims_per_client(self):
366367

367368
session_id = self._create_session(_auth_req)
368369
grant = self.session_manager[session_id]
370+
grant.scope = _auth_req["scope"]
369371
access_token = self._mint_token("access_token", grant, session_id)
370372

371373
self.endpoint.kwargs["add_claims_by_scope"] = True

0 commit comments

Comments
 (0)