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

Commit 5a13dbf

Browse files
committed
More descriptive name.
1 parent 662e7d7 commit 5a13dbf

7 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/oidcop/session/claims.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def available_claims(endpoint_context):
2525

2626
class ClaimsInterface:
2727
init_args = {"add_claims_by_scope": False, "enable_claims_per_client": False}
28-
claims_types = ["userinfo", "introspection", "id_token", "access_token"]
28+
claims_release_points = ["userinfo", "introspection", "id_token", "access_token"]
2929

3030
def __init__(self, server_get):
3131
self.server_get = server_get
3232

3333
def authorization_request_claims(self,
3434
session_id: str,
35-
claims_release_ref: Optional[str] = "") -> dict:
35+
claims_release_point: Optional[str] = "") -> dict:
3636
_grant = self.server_get("endpoint_context").session_manager.get_grant(session_id)
3737
if _grant.authorization_request and "claims" in _grant.authorization_request:
38-
return _grant.authorization_request["claims"].get(claims_release_ref, {})
38+
return _grant.authorization_request["claims"].get(claims_release_point, {})
3939

4040
return {}
4141

@@ -65,19 +65,19 @@ def _get_module(self, usage, endpoint_context):
6565

6666
return module
6767

68-
def get_claims(self, session_id: str, scopes: str, claims_release_ref: str) -> dict:
68+
def get_claims(self, session_id: str, scopes: str, claims_release_point: str) -> dict:
6969
"""
7070
7171
:param session_id: Session identifier
7272
:param scopes: Scopes
73-
:param claims_release_ref: Where to release the claims. One of
73+
:param claims_release_point: Where to release the claims. One of
7474
"userinfo"/"id_token"/"introspection"/"access_token"
7575
:return: Claims specification as a dictionary.
7676
"""
7777

7878
_context = self.server_get("endpoint_context")
7979
# which endpoint module configuration to get the base claims from
80-
module = self._get_module(claims_release_ref, _context)
80+
module = self._get_module(claims_release_point, _context)
8181

8282
if module:
8383
base_claims = module.kwargs.get("base_claims", {})
@@ -88,7 +88,7 @@ def get_claims(self, session_id: str, scopes: str, claims_release_ref: str) -> d
8888

8989
# Can there be per client specification of which claims to use.
9090
if module.kwargs.get("enable_claims_per_client"):
91-
claims = self._get_client_claims(client_id, claims_release_ref)
91+
claims = self._get_client_claims(client_id, claims_release_point)
9292
else:
9393
claims = {}
9494

@@ -105,7 +105,7 @@ def get_claims(self, session_id: str, scopes: str, claims_release_ref: str) -> d
105105
# Bring in claims specification from the authorization request
106106
# This only goes for ID Token and user info
107107
request_claims = self.authorization_request_claims(session_id=session_id,
108-
claims_release_ref=claims_release_ref)
108+
claims_release_point=claims_release_point)
109109

110110
# This will add claims that has not be added before and
111111
# set filters on those claims that also appears in one of the sources above
@@ -116,7 +116,7 @@ def get_claims(self, session_id: str, scopes: str, claims_release_ref: str) -> d
116116

117117
def get_claims_all_usage(self, session_id: str, scopes: str) -> dict:
118118
_claims = {}
119-
for usage in self.claims_types:
119+
for usage in self.claims_release_points:
120120
_claims[usage] = self.get_claims(session_id, scopes, usage)
121121
return _claims
122122

@@ -192,7 +192,7 @@ def by_schema(cls, **kwa):
192192

193193

194194
class OAuth2ClaimsInterface(ClaimsInterface):
195-
claims_types = ["introspection", "access_token"]
195+
claims_release_points = ["introspection", "access_token"]
196196

197197
def _get_module(self, usage, endpoint_context):
198198
module = None
@@ -208,6 +208,6 @@ def _get_module(self, usage, endpoint_context):
208208

209209
def get_claims_all_usage(self, session_id: str, scopes: str) -> dict:
210210
_claims = {}
211-
for usage in self.claims_types:
211+
for usage in self.claims_release_points:
212212
_claims[usage] = self.get_claims(session_id, scopes, usage)
213213
return _claims

src/oidcop/session/grant.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ def payload_arguments(
171171
self,
172172
session_id: str,
173173
endpoint_context,
174-
claims_release_ref: str,
174+
claims_release_point: str,
175175
scope: Optional[dict] = None,
176176
extra_payload: Optional[dict] = None,
177177
) -> dict:
178178
"""
179179
180180
:param session_id:
181181
:param endpoint_context:
182-
:param claims_release_ref: One of "userinfo", "introspection", "id_token", "access_token"
182+
:param claims_release_point: One of "userinfo", "introspection", "id_token", "access_token"
183183
:param scope:
184184
:param extra_payload:
185185
:return: dictionary containing information to place in a token value
@@ -202,7 +202,7 @@ def payload_arguments(
202202
payload.update({"client_id": client_id, "sub": client_id})
203203

204204
_claims_restriction = endpoint_context.claims_interface.get_claims(
205-
session_id, scopes=scope, claims_release_ref=claims_release_ref
205+
session_id, scopes=scope, claims_release_point=claims_release_point
206206
)
207207
user_id, _, _ = endpoint_context.session_manager.decrypt_session_id(session_id)
208208
user_info = endpoint_context.claims_interface.get_user_claims(user_id, _claims_restriction)
@@ -269,14 +269,14 @@ def mint_token(
269269

270270
# Only access_token and id_token can give rise to claims release
271271
if token_class in ["access_token", "id_token"]:
272-
claims_release_ref = token_class
272+
claims_release_point = token_class
273273
else:
274-
claims_release_ref = ""
274+
claims_release_point = ""
275275

276276
token_payload = self.payload_arguments(
277277
session_id,
278278
endpoint_context,
279-
claims_release_ref=claims_release_ref,
279+
claims_release_point=claims_release_point,
280280
scope=scope,
281281
extra_payload=handler_args,
282282
)

tests/test_05_id_token.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def test_client_claims(self):
419419
self.endpoint_context.cdb["client_1"]["id_token_claims"] = {"address": None}
420420

421421
_claims = self.endpoint_context.claims_interface.get_claims(
422-
session_id=session_id, scopes=AREQ["scope"], claims_release_ref="id_token"
422+
session_id=session_id, scopes=AREQ["scope"], claims_release_point="id_token"
423423
)
424424
grant.claims = {"id_token": _claims}
425425

@@ -438,7 +438,7 @@ def test_client_claims_with_default(self):
438438
grant = self.session_manager[session_id]
439439

440440
_claims = self.endpoint_context.claims_interface.get_claims(
441-
session_id=session_id, scopes=AREQ["scope"], claims_release_ref="id_token"
441+
session_id=session_id, scopes=AREQ["scope"], claims_release_point="id_token"
442442
)
443443
grant.claims = {"id_token": _claims}
444444

@@ -461,7 +461,7 @@ def test_client_claims_scopes(self):
461461
self.session_manager.token_handler["id_token"].kwargs["add_claims_by_scope"] = True
462462

463463
_claims = self.endpoint_context.claims_interface.get_claims(
464-
session_id=session_id, scopes=AREQS["scope"], claims_release_ref="id_token"
464+
session_id=session_id, scopes=AREQS["scope"], claims_release_point="id_token"
465465
)
466466
grant.claims = {"id_token": _claims}
467467

@@ -483,7 +483,7 @@ def test_client_claims_scopes_and_request_claims_no_match(self):
483483
self.session_manager.token_handler["id_token"].kwargs["add_claims_by_scope"] = True
484484

485485
_claims = self.endpoint_context.claims_interface.get_claims(
486-
session_id=session_id, scopes=AREQRC["scope"], claims_release_ref="id_token"
486+
session_id=session_id, scopes=AREQRC["scope"], claims_release_point="id_token"
487487
)
488488
grant.claims = {"id_token": _claims}
489489

@@ -510,7 +510,7 @@ def test_client_claims_scopes_and_request_claims_one_match(self):
510510
self.session_manager.token_handler["id_token"].kwargs["add_claims_by_scope"] = True
511511

512512
_claims = self.endpoint_context.claims_interface.get_claims(
513-
session_id=session_id, scopes=_req["scope"], claims_release_ref="id_token"
513+
session_id=session_id, scopes=_req["scope"], claims_release_point="id_token"
514514
)
515515
grant.claims = {"id_token": _claims}
516516

tests/test_07_userinfo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_collect_user_info(self):
280280
session_id = self._create_session(_req)
281281

282282
_userinfo_restriction = self.claims_interface.get_claims(
283-
session_id=session_id, scopes=OIDR["scope"], claims_release_ref="userinfo"
283+
session_id=session_id, scopes=OIDR["scope"], claims_release_point="userinfo"
284284
)
285285

286286
res = self.claims_interface.get_user_claims("diana", _userinfo_restriction)
@@ -293,7 +293,7 @@ def test_collect_user_info(self):
293293
}
294294

295295
_id_token_restriction = self.claims_interface.get_claims(
296-
session_id=session_id, scopes=OIDR["scope"], claims_release_ref="id_token"
296+
session_id=session_id, scopes=OIDR["scope"], claims_release_point="id_token"
297297
)
298298

299299
res = self.claims_interface.get_user_claims("diana", _id_token_restriction)
@@ -304,7 +304,7 @@ def test_collect_user_info(self):
304304
}
305305

306306
_restriction = self.claims_interface.get_claims(
307-
session_id=session_id, scopes=OIDR["scope"], claims_release_ref="introspection"
307+
session_id=session_id, scopes=OIDR["scope"], claims_release_point="introspection"
308308
)
309309

310310
res = self.claims_interface.get_user_claims("diana", _restriction)
@@ -320,7 +320,7 @@ def test_collect_user_info_2(self):
320320
_uid, _cid, _gid = self.session_manager.decrypt_session_id(session_id)
321321

322322
_userinfo_restriction = self.claims_interface.get_claims(
323-
session_id=session_id, scopes=_req["scope"], claims_release_ref="userinfo"
323+
session_id=session_id, scopes=_req["scope"], claims_release_point="userinfo"
324324
)
325325

326326
res = self.claims_interface.get_user_claims("diana", _userinfo_restriction)
@@ -351,7 +351,7 @@ def test_collect_user_info_scope_not_supported_no_base_claims(self):
351351
del _userinfo_endpoint.kwargs["base_claims"]
352352

353353
_userinfo_restriction = self.claims_interface.get_claims(
354-
session_id=session_id, scopes=_req["scope"], claims_release_ref="userinfo"
354+
session_id=session_id, scopes=_req["scope"], claims_release_point="userinfo"
355355
)
356356

357357
res = self.claims_interface.get_user_claims("diana", _userinfo_restriction)
@@ -374,7 +374,7 @@ def test_collect_user_info_enable_claims_per_client(self):
374374
self.endpoint_context.cdb[_req["client_id"]]["userinfo_claims"] = {"phone_number": None}
375375

376376
_userinfo_restriction = self.claims_interface.get_claims(
377-
session_id=session_id, scopes=_req["scope"], claims_release_ref="userinfo"
377+
session_id=session_id, scopes=_req["scope"], claims_release_point="userinfo"
378378
)
379379

380380
res = self.claims_interface.get_user_claims("diana", _userinfo_restriction)
@@ -495,7 +495,7 @@ def test_collect_user_info_custom_scope(self):
495495
session_id = self._create_session(_req)
496496

497497
_restriction = self.claims_interface.get_claims(
498-
session_id=session_id, scopes=_req["scope"], claims_release_ref="userinfo"
498+
session_id=session_id, scopes=_req["scope"], claims_release_point="userinfo"
499499
)
500500

501501
res = self.claims_interface.get_user_claims("diana", _restriction)

tests/test_26_oidc_userinfo_endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def test_custom_scope(self):
324324
self.endpoint.server_get("endpoint_context").claims_interface.add_claims_by_scope = True
325325
grant.claims = {
326326
"userinfo": self.endpoint.server_get("endpoint_context").claims_interface.get_claims(
327-
session_id=session_id, scopes=_auth_req["scope"], claims_release_ref="userinfo"
327+
session_id=session_id, scopes=_auth_req["scope"], claims_release_point="userinfo"
328328
)
329329
}
330330

tests/test_31_oauth2_introspection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def test_introspection_claims(self):
389389
_c_interface = self.introspection_endpoint.server_get("endpoint_context").claims_interface
390390
grant.claims = {
391391
"introspection": _c_interface.get_claims(
392-
session_id, scopes=AUTH_REQ["scope"], claims_release_ref="introspection"
392+
session_id, scopes=AUTH_REQ["scope"], claims_release_point="introspection"
393393
)
394394
}
395395

tests/test_50_persistence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def test_custom_scope(self):
410410
"userinfo": self.endpoint[1]
411411
.server_get("endpoint_context")
412412
.claims_interface.get_claims(session_id, scopes=_auth_req["scope"],
413-
claims_release_ref="userinfo")
413+
claims_release_point="userinfo")
414414
}
415415

416416
self._dump_restore(1, 2)

0 commit comments

Comments
 (0)