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

Commit ddb861b

Browse files
committed
Rename scopes_mapping to scopes_to_claims
1 parent 946f20f commit ddb861b

8 files changed

Lines changed: 33 additions & 33 deletions

File tree

docs/source/contents/conf.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ sub_funcs
5454
Optional. Functions involved in *sub*ject value creation.
5555
5656

57-
scopes_mapping
57+
scopes_to_claims
5858
##############
5959

6060
A dict defining the scopes that are allowed to be used per client and the claims
@@ -71,7 +71,7 @@ simply map it to an empty list. E.g.::
7171
allowed_scopes
7272
##############
7373

74-
A list with the scopes that are allowed to be used (defaults to the keys in scopes_mapping).
74+
A list with the scopes that are allowed to be used (defaults to the keys in scopes_to_claims).
7575

7676

7777
scopes_supported
@@ -736,7 +736,7 @@ grant_types_supported
736736
Configure the allowed grant types on the token endpoint.
737737

738738
--------------
739-
scopes_mapping
739+
scopes_to_claims
740740
--------------
741741

742742
A dict defining the scopes that are allowed to be used per client and the claims
@@ -753,4 +753,4 @@ allowed_scopes
753753
--------------
754754

755755
A list with the scopes that are allowed to be used (defaults to the keys in the
756-
clients scopes_mapping).
756+
clients scopes_to_claims).

src/oidcop/configure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"refresh": {"class": "oidcop.token.jwt_token.JWTToken", "kwargs": {"lifetime": 86400}, },
8080
"id_token": {"class": "oidcop.token.id_token.IDToken", "kwargs": {}},
8181
},
82-
"scopes_mapping": SCOPE2CLAIMS,
82+
"scopes_to_claims": SCOPE2CLAIMS,
8383
}
8484

8585
AS_DEFAULT_CONFIG = copy.deepcopy(OP_DEFAULT_CONFIG)
@@ -282,7 +282,7 @@ class OPConfiguration(EntityConfiguration):
282282
"login_hint2acrs": {},
283283
"login_hint_lookup": None,
284284
"sub_func": {},
285-
"scopes_mapping": {},
285+
"scopes_to_claims": {},
286286
}
287287
)
288288

@@ -303,7 +303,7 @@ def __init__(
303303
port=port,
304304
file_attributes=file_attributes,
305305
)
306-
scopes_mapping = self.scopes_mapping
306+
scopes_to_claims = self.scopes_to_claims
307307

308308

309309
class ASConfiguration(EntityConfiguration):

src/oidcop/endpoint_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def set_scopes_handler(self):
257257
self.scopes_handler = Scopes(
258258
self.server_get,
259259
allowed_scopes=self.conf.get("allowed_scopes"),
260-
scopes_mapping=self.conf.get("scopes_mapping"),
260+
scopes_to_claims=self.conf.get("scopes_to_claims"),
261261
)
262262

263263
def do_add_on(self, endpoints):

src/oidcop/oidc/add_on/custom_scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ def add_custom_scopes(endpoint, **kwargs):
1111
"""
1212
# Just need an endpoint, anyone will do
1313
LOGGER.warning(
14-
"The custom_scopes add on is deprecated. The `scopes_mapping` config "
14+
"The custom_scopes add on is deprecated. The `scopes_to_claims` config "
1515
"option should be used instead."
1616
)
1717
_endpoint = list(endpoint.values())[0]
1818

1919
_scopes2claims = SCOPE2CLAIMS.copy()
2020
_scopes2claims.update(kwargs)
2121
_context = _endpoint.server_get("endpoint_context")
22-
_context.scopes_handler.scopes_mapping = _scopes2claims
22+
_context.scopes_handler.scopes_to_claims = _scopes2claims
2323

2424
pi = _context.provider_info
2525
_scopes = set(pi.get("scopes_supported", []))

src/oidcop/scopes.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def convert_scopes2claims(scopes, allowed_claims=None, scope2claim_map=None):
4545

4646

4747
class Scopes:
48-
def __init__(self, server_get, allowed_scopes=None, scopes_mapping=None):
48+
def __init__(self, server_get, allowed_scopes=None, scopes_to_claims=None):
4949
self.server_get = server_get
50-
if not scopes_mapping:
51-
scopes_mapping = dict(SCOPE2CLAIMS)
52-
self.scopes_mapping = scopes_mapping
50+
if not scopes_to_claims:
51+
scopes_to_claims = dict(SCOPE2CLAIMS)
52+
self._scopes_to_claims = scopes_to_claims
5353
if not allowed_scopes:
54-
allowed_scopes = list(scopes_mapping.keys())
54+
allowed_scopes = list(scopes_to_claims.keys())
5555
self.allowed_scopes = allowed_scopes
5656

5757
def get_allowed_scopes(self, client_id=None):
@@ -67,8 +67,8 @@ def get_allowed_scopes(self, client_id=None):
6767
if client is not None:
6868
if "allowed_scopes" in client:
6969
allowed_scopes = client.get("allowed_scopes")
70-
elif "scopes_mapping" in client:
71-
allowed_scopes = list(client.get("scopes_mapping").keys())
70+
elif "scopes_to_claims" in client:
71+
allowed_scopes = list(client.get("scopes_to_claims").keys())
7272

7373
return allowed_scopes
7474

@@ -79,21 +79,21 @@ def get_scopes_mapping(self, client_id=None):
7979
:param client_id: The client identifier
8080
:returns: Dict of scopes to claims. Can be empty.
8181
"""
82-
scopes_mapping = self.scopes_mapping
82+
scopes_to_claims = self._scopes_to_claims
8383
if client_id:
8484
client = self.server_get("endpoint_context").cdb.get(client_id)
8585
if client is not None:
86-
scopes_mapping = client.get("scopes_mapping", scopes_mapping)
87-
return scopes_mapping
86+
scopes_to_claims = client.get("scopes_to_claims", scopes_to_claims)
87+
return scopes_to_claims
8888

8989
def filter_scopes(self, scopes, client_id=None):
9090
allowed_scopes = self.get_allowed_scopes(client_id)
9191
return [s for s in scopes if s in allowed_scopes]
9292

93-
def scopes_to_claims(self, scopes, scopes_mapping=None, client_id=None):
94-
if not scopes_mapping:
95-
scopes_mapping = self.get_scopes_mapping(client_id)
93+
def scopes_to_claims(self, scopes, scopes_to_claims=None, client_id=None):
94+
if not scopes_to_claims:
95+
scopes_to_claims = self.get_scopes_mapping(client_id)
9696

9797
scopes = self.filter_scopes(scopes, client_id)
9898

99-
return convert_scopes2claims(scopes, scope2claim_map=scopes_mapping)
99+
return convert_scopes2claims(scopes, scope2claim_map=scopes_to_claims)

tests/test_07_userinfo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def conf(self):
440440
},
441441
},
442442
},
443-
"scopes_mapping": {
443+
"scopes_to_claims": {
444444
"openid": ["sub"],
445445
"research_and_scholarship": [
446446
"name",
@@ -521,13 +521,13 @@ def test_collect_user_info_custom_scope(self):
521521
}
522522

523523
def test_collect_user_info_scope_mapping_per_client(self, conf):
524-
conf["scopes_mapping"] = SCOPE2CLAIMS
524+
conf["scopes_to_claims"] = SCOPE2CLAIMS
525525
server = Server(conf)
526526
endpoint_context = server.endpoint_context
527527
self.session_manager = endpoint_context.session_manager
528528
claims_interface = endpoint_context.claims_interface
529529
endpoint_context.cdb["client1"] = {
530-
"scopes_mapping": {
530+
"scopes_to_claims": {
531531
"openid": ["sub"],
532532
"research_and_scholarship": [
533533
"name",

tests/test_26_oidc_userinfo_endpoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def create_endpoint(self):
149149

150150
},
151151
"template_dir": "template",
152-
"scopes_mapping": {
152+
"scopes_to_claims": {
153153
**SCOPE2CLAIMS,
154154
"research_and_scholarship": [
155155
"name",
@@ -317,7 +317,7 @@ def test_do_signed_response(self):
317317
res = self.endpoint.do_response(request=_req, **args)
318318
assert res
319319

320-
def test_scopes_mapping(self):
320+
def test_scopes_to_claims(self):
321321
_auth_req = AUTH_REQ.copy()
322322
_auth_req["scope"] = ["openid", "research_and_scholarship"]
323323

@@ -347,8 +347,8 @@ def test_scopes_mapping(self):
347347
"sub",
348348
}
349349

350-
def test_scopes_mapping_per_client(self):
351-
self.endpoint_context.cdb["client_1"]["scopes_mapping"] = {
350+
def test_scopes_to_claims_per_client(self):
351+
self.endpoint_context.cdb["client_1"]["scopes_to_claims"] = {
352352
**SCOPE2CLAIMS,
353353
"research_and_scholarship_2": [
354354
"name",
@@ -415,7 +415,7 @@ def test_allowed_scopes(self):
415415
assert set(args["response_args"].keys()) == {"sub"}
416416

417417
def test_allowed_scopes_per_client(self):
418-
self.endpoint_context.cdb["client_1"]["scopes_mapping"] = {
418+
self.endpoint_context.cdb["client_1"]["scopes_to_claims"] = {
419419
**SCOPE2CLAIMS,
420420
"research_and_scholarship_2": [
421421
"name",

tests/test_50_persistence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def full_path(local_file):
137137
}
138138
},
139139
"template_dir": "template",
140-
"scopes_mapping": {
140+
"scopes_to_claims": {
141141
**SCOPE2CLAIMS,
142142
"research_and_scholarship": [
143143
"name",

0 commit comments

Comments
 (0)