Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/oidcop/endpoint_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def create_providerinfo(self, capabilities):
_provider_info["jwks_uri"] = self.jwks_uri

if "scopes_supported" not in _provider_info:
_provider_info["scopes_supported"] = [s for s in self.scope2claims.keys()]
_provider_info["scopes_supported"] = [
s for s in self.scope2claims.keys()
]
if "claims_supported" not in _provider_info:
_provider_info["claims_supported"] = STANDARD_CLAIMS[:]

Expand Down
13 changes: 8 additions & 5 deletions src/oidcop/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ def available_scopes(endpoint_context):
return [s for s in endpoint_context.scope2claims.keys()]


def convert_scopes2claims(scopes, allowed_claims=None, map=None):
if map is None:
map = SCOPE2CLAIMS
def convert_scopes2claims(scopes, allowed_claims=None, scope2claim_map=None):
scope2claim_map = scope2claim_map or SCOPE2CLAIMS

res = {}
if allowed_claims is None:
for scope in scopes:
claims = {name: None for name in map[scope]}
claims = {name: None for name in scope2claim_map[scope]}
res.update(claims)
else:
for scope in scopes:
try:
claims = {name: None for name in map[scope] if name in allowed_claims}
claims = {
name: None
for name in scope2claim_map[scope]
if name in allowed_claims
}
res.update(claims)
except KeyError:
continue
Expand Down
4 changes: 3 additions & 1 deletion src/oidcop/session/claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def get_claims(self, session_id: str, scopes: str, usage: str) -> dict:
client_id, _context, scopes
)

_claims = convert_scopes2claims(_scopes, map=_context.scope2claims)
_claims = convert_scopes2claims(
_scopes, scope2claim_map=_context.scope2claims
)
claims.update(_claims)

# Bring in claims specification from the authorization request
Expand Down
2 changes: 1 addition & 1 deletion tests/op_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"id_token": {
"class": "oidcop.id_token.IDToken",
"kwargs": {
"default_claims": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see a disalignment on which variable name we must use.
I found this in op_config and base_claims in test.

I'm using base_claims, no problem to switch to default_claims, just need to decide which one to use and then a final alignment of code and documentation must be done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should always be base_claims. I think I went through the code base yesterday and fixed that everywhere.

"base_claims": {
"email": {
"essential": true
},
Expand Down
8 changes: 4 additions & 4 deletions tests/test_07_userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ def test_custom_scopes():
_available_claims.append("eduperson_scoped_affiliation")

assert set(
convert_scopes2claims(["email"], _available_claims, map=_scopes).keys()
convert_scopes2claims(["email"], _available_claims, scope2claim_map=_scopes).keys()
) == {"email", "email_verified",}
assert set(
convert_scopes2claims(["address"], _available_claims, map=_scopes).keys()
convert_scopes2claims(["address"], _available_claims, scope2claim_map=_scopes).keys()
) == {"address"}
assert set(
convert_scopes2claims(["phone"], _available_claims, map=_scopes).keys()
convert_scopes2claims(["phone"], _available_claims, scope2claim_map=_scopes).keys()
) == {"phone_number", "phone_number_verified",}

assert set(
convert_scopes2claims(
["research_and_scholarship"], _available_claims, map=_scopes
["research_and_scholarship"], _available_claims, scope2claim_map=_scopes
).keys()
) == {
"name",
Expand Down