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

Commit 49c6cec

Browse files
committed
Don't require a scope to be defined
Scopes that don't map to claims shouldn't have to be defined in the scopes to claims mapping
1 parent 82cb13a commit 49c6cec

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/oidcop/scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def convert_scopes2claims(scopes, allowed_claims=None, scope2claim_map=None):
3131
res = {}
3232
if allowed_claims is None:
3333
for scope in scopes:
34-
claims = {name: None for name in scope2claim_map[scope]}
34+
claims = {name: None for name in scope2claim_map.get(scope, [])}
3535
res.update(claims)
3636
else:
3737
for scope in scopes:
3838
try:
39-
claims = {name: None for name in scope2claim_map[scope] if name in allowed_claims}
39+
claims = {name: None for name in scope2claim_map.get(scope, []) if name in allowed_claims}
4040
res.update(claims)
4141
except KeyError:
4242
continue

tests/test_26_oidc_userinfo_endpoint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,10 @@ def test_scopes_to_claims_per_client(self):
360360
"eduperson_scoped_affiliation",
361361
],
362362
}
363+
self.endpoint_context.cdb["client_1"]["allowed_scopes"] = list(self.endpoint_context.cdb["client_1"]["scopes_to_claims"].keys()) + ["aba"]
363364

364365
_auth_req = AUTH_REQ.copy()
365-
_auth_req["scope"] = ["openid", "research_and_scholarship_2"]
366+
_auth_req["scope"] = ["openid", "research_and_scholarship_2", "aba"]
366367

367368
session_id = self._create_session(_auth_req)
368369
grant = self.session_manager[session_id]

0 commit comments

Comments
 (0)