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

Commit 109f86a

Browse files
committed
Translating scopes to claims is not something that should happen at the RP.
1 parent d257fa2 commit 109f86a

File tree

2 files changed

+1
-44
lines changed

2 files changed

+1
-44
lines changed

src/oidcmsg/oidc/__init__.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,30 +1135,6 @@ class ClaimsRequest(Message):
11351135
}
11361136

11371137

1138-
SCOPE2CLAIMS = {
1139-
"openid": ["sub"],
1140-
"profile": ["name", "given_name", "family_name", "middle_name",
1141-
"nickname", "profile", "picture", "website", "gender",
1142-
"birthdate", "zoneinfo", "locale", "updated_at",
1143-
"preferred_username"],
1144-
"email": ["email", "email_verified"],
1145-
"address": ["address"],
1146-
"phone": ["phone_number", "phone_number_verified"],
1147-
"offline_access": []
1148-
}
1149-
1150-
1151-
def scope2claims(scopes):
1152-
res = {}
1153-
for scope in scopes:
1154-
try:
1155-
claims = dict([(name, None) for name in SCOPE2CLAIMS[scope]])
1156-
res.update(claims)
1157-
except KeyError:
1158-
continue
1159-
return res
1160-
1161-
11621138
def factory(msgtype, **kwargs):
11631139
for name, obj in inspect.getmembers(sys.modules[__name__]):
11641140
if inspect.isclass(obj) and issubclass(obj, Message):
@@ -1195,7 +1171,7 @@ def claims_match(value, claimspec):
11951171
Implements matching according to section 5.5.1 of
11961172
http://openid.net/specs/openid-connect-core-1_0.html
11971173
The lack of value is not checked here.
1198-
Also the text doesn't prohibit claims specification having both 'value'
1174+
Also the text doesn't prohibit claims specification having both 'value'
11991175
and 'values'.
12001176
12011177
:param value: single value

tests/test_6_oidc.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from oidcmsg.oidc import factory
5050
from oidcmsg.oidc import msg_ser
5151
from oidcmsg.oidc import msg_ser_json
52-
from oidcmsg.oidc import scope2claims
5352
from oidcmsg.oidc import verified_claim_name
5453
from oidcmsg.time_util import utc_time_sans_frac
5554

@@ -985,24 +984,6 @@ def test_factory_chain():
985984
assert list(dr.keys()) == ['error']
986985

987986

988-
def test_scope2claims():
989-
assert scope2claims(['openid']) == {'sub': None}
990-
assert set(scope2claims(['profile']).keys()) == {
991-
"name", "given_name", "family_name", "middle_name", "nickname",
992-
"profile", "picture", "website", "gender", "birthdate", "zoneinfo",
993-
"locale", "updated_at", "preferred_username"}
994-
assert set(scope2claims(['email']).keys()) == {"email", "email_verified"}
995-
assert set(scope2claims(['address']).keys()) == {'address'}
996-
assert set(scope2claims(['phone']).keys()) == {"phone_number",
997-
"phone_number_verified"}
998-
assert scope2claims(['offline_access']) == {}
999-
1000-
assert scope2claims(['openid', 'email', 'phone']) == {
1001-
'sub': None, "email": None, "email_verified": None,
1002-
"phone_number": None, "phone_number_verified": None
1003-
}
1004-
1005-
1006987
def test_dict_deser():
1007988
_info = {'foo': 'bar'}
1008989

0 commit comments

Comments
 (0)