Skip to content

Commit 4eb8214

Browse files
authored
Merge pull request #61 from IdentityPython/callable2function
Replace the name callable with function.
2 parents bfbb452 + 48ecfc9 commit 4eb8214

13 files changed

+54
-54
lines changed

src/idpyoidc/server/oauth2/authorization.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def _post_parse_request(self, request, client_id, context, **kwargs):
526526

527527
if resource_indicators_config is not None:
528528
if "policy" not in resource_indicators_config:
529-
policy = {"policy": {"callable": validate_resource_indicators_policy}}
529+
policy = {"policy": {"function": validate_resource_indicators_policy}}
530530
resource_indicators_config.update(policy)
531531
request = self._enforce_resource_indicators_policy(request, resource_indicators_config)
532532

@@ -536,25 +536,25 @@ def _enforce_resource_indicators_policy(self, request, config):
536536
_context = self.upstream_get("context")
537537

538538
policy = config["policy"]
539-
callable = policy["callable"]
539+
function = policy["function"]
540540
kwargs = policy.get("kwargs", {})
541541

542542
if kwargs.get("resource_servers_per_client", None) is None:
543543
kwargs["resource_servers_per_client"] = {
544544
request["client_id"]: request["client_id"]
545545
}
546546

547-
if isinstance(callable, str):
547+
if isinstance(function, str):
548548
try:
549-
fn = importer(callable)
549+
fn = importer(function)
550550
except Exception:
551-
raise ImproperlyConfigured(f"Error importing {callable} policy callable")
551+
raise ImproperlyConfigured(f"Error importing {function} policy function")
552552
else:
553-
fn = callable
553+
fn = function
554554
try:
555555
return fn(request, context=_context, **kwargs)
556556
except Exception as e:
557-
logger.error(f"Error while executing the {fn} policy callable: {e}")
557+
logger.error(f"Error while executing the {fn} policy function: {e}")
558558
return self.error_cls(error="server_error", error_description="Internal server error")
559559

560560
def pick_authn_method(self, request, redirect_uri, acr=None, **kwargs):

src/idpyoidc/server/oauth2/token_helper/access_token.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def process_request(self, req: Union[Message, dict], **kwargs):
5858

5959
if resource_indicators_config is not None:
6060
if "policy" not in resource_indicators_config:
61-
policy = {"policy": {"callable": validate_resource_indicators_policy}}
61+
policy = {"policy": {"function": validate_resource_indicators_policy}}
6262
resource_indicators_config.update(policy)
6363

6464
req = self._enforce_resource_indicators_policy(req, resource_indicators_config)
@@ -152,20 +152,20 @@ def _enforce_resource_indicators_policy(self, request, config):
152152
_context = self.endpoint.upstream_get('context')
153153

154154
policy = config["policy"]
155-
callable = policy["callable"]
155+
function = policy["function"]
156156
kwargs = policy.get("kwargs", {})
157157

158-
if isinstance(callable, str):
158+
if isinstance(function, str):
159159
try:
160-
fn = importer(callable)
160+
fn = importer(function)
161161
except Exception:
162-
raise ImproperlyConfigured(f"Error importing {callable} policy callable")
162+
raise ImproperlyConfigured(f"Error importing {function} policy function")
163163
else:
164-
fn = callable
164+
fn = function
165165
try:
166166
return fn(request, context=_context, **kwargs)
167167
except Exception as e:
168-
logger.error(f"Error while executing the {fn} policy callable: {e}")
168+
logger.error(f"Error while executing the {fn} policy function: {e}")
169169
return self.error_cls(error="server_error", error_description="Internal server error")
170170

171171
def post_parse_request(

src/idpyoidc/server/oauth2/token_helper/token_exchange.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, endpoint, config=None):
4141
"urn:ietf:params:oauth:token-type:refresh_token",
4242
],
4343
"default_requested_token_type": "urn:ietf:params:oauth:token-type:access_token",
44-
"policy": {"": {"callable": validate_token_exchange_policy}},
44+
"policy": {"": {"function": validate_token_exchange_policy}},
4545
}
4646
else:
4747
self.config = config
@@ -154,21 +154,21 @@ def _enforce_policy(self, request, token, config):
154154
subject_token_type = ""
155155

156156
policy = config["policy"][subject_token_type]
157-
callable = policy["callable"]
157+
function = policy["function"]
158158
kwargs = policy.get("kwargs", {})
159159

160-
if isinstance(callable, str):
160+
if isinstance(function, str):
161161
try:
162-
fn = importer(callable)
162+
fn = importer(function)
163163
except Exception:
164-
raise ImproperlyConfigured(f"Error importing {callable} policy callable")
164+
raise ImproperlyConfigured(f"Error importing {function} policy function")
165165
else:
166-
fn = callable
166+
fn = function
167167

168168
try:
169169
return fn(request, context=_context, subject_token=token, **kwargs)
170170
except Exception as e:
171-
logger.error(f"Error while executing the {fn} policy callable: {e}")
171+
logger.error(f"Error while executing the {fn} policy function: {e}")
172172
return self.error_cls(error="server_error", error_description="Internal server error")
173173

174174
def token_exchange_response(self, token, issued_token_type):
@@ -285,9 +285,9 @@ def _validate_configuration(self, config):
285285
raise ImproperlyConfigured(
286286
"Default Token Exchange policy configuration is not defined"
287287
)
288-
if "callable" not in config["policy"][""]:
288+
if "function" not in config["policy"][""]:
289289
raise ImproperlyConfigured(
290-
"Missing 'callable' from default Token Exchange policy configuration"
290+
"Missing 'function' from default Token Exchange policy configuration"
291291
)
292292

293293
_default_requested_token_type = config.get("default_requested_token_type",

src/idpyoidc/server/oauth2/token_revocation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def process_request(self, request=None, **kwargs):
8686
self.policy = _context.cdb[client_id]["token_revocation"]["policy"]
8787
except Exception:
8888
self.policy = self.token_revocation_kwargs.get("policy", {
89-
"": {"callable": validate_token_revocation_policy}})
89+
"": {"function": validate_token_revocation_policy}})
9090

9191
if _token.token_class not in self.token_types_supported:
9292
desc = (
@@ -108,21 +108,21 @@ def _revoke(self, request, session_info):
108108
_cls = ""
109109

110110
temp_policy = self.policy[_cls]
111-
callable = temp_policy["callable"]
111+
function = temp_policy["function"]
112112
kwargs = temp_policy.get("kwargs", {})
113113

114-
if isinstance(callable, str):
114+
if isinstance(function, str):
115115
try:
116-
fn = importer(callable)
116+
fn = importer(function)
117117
except Exception:
118-
raise ImproperlyConfigured(f"Error importing {callable} policy callable")
118+
raise ImproperlyConfigured(f"Error importing {function} policy function")
119119
else:
120-
fn = callable
120+
fn = function
121121

122122
try:
123123
return fn(_token, session_info=session_info, **kwargs)
124124
except Exception as e:
125-
logger.error(f"Error while executing the {fn} policy callable: {e}")
125+
logger.error(f"Error while executing the {fn} policy function: {e}")
126126
return self.error_cls(error="server_error", error_description="Internal server error")
127127

128128

tests/private/token_jwks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}, {"kty": "oct", "use": "enc", "kid": "refresh", "k": "nSZ0kdDYyJn4d0Oy67Z1okgykXRhCcKk"}]}
1+
{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}, {"kty": "oct", "use": "enc", "kid": "refresh", "k": "XeeoaV1P5eINXBFEDU2U_YBXqsjJE0uD"}]}

tests/pub_client.jwks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "EC", "use": "sig", "kid": "azZQQ2FEQjh3QnVZWVdrbHJkMEZSaWR6aVJ0LTBjeUFfeWRlbTRrRFZ5VQ", "crv": "P-256", "x": "2ADe18caWWGp6hpRbfa9HqQHDFNpid9xUmR56Wzm_wc", "y": "HnD_8QBanz4Y-UF8mKQFZXfqkGkXUSm34mLsdDKtSyk"}, {"kty": "RSA", "use": "sig", "kid": "SHEyYWcwNVk0LTdROTZzZ2FUWndIVXdack0xWUM5SEpwcS03dVUxWU4zRQ", "e": "AQAB", "n": "rRz52ddyP9Y2ezSlRsnkt-sjXfV_Ii7vOFX-cStLE3IUlVeSJGEe_kAASLr2r3BE2unjntaxj67NP8D95h_rzG1SpCklTEn-aTe3FOwNyTzUH_oiDVeRoEcf04Y43ciRGYRB5PhI6ii-2lYuig6hyUr776Qxiu6-0zw-M_ay2MgGSy5CEj55dDSvcUyxStUObxGpPWnEvybO1vnE7iJEWGNe0L5uPe5nLidOiR-JwjxSWEx1xZYtIjxaf2Ulu-qu4hwgwBUQdx4bNZyBfljKj55skWuHqPMG3xMjnedQC6Ms5bR3rIkbBpvmgI3kJK-4CZikM6ruyLo94-Lk19aYQw"}]}
1+
{"keys": [{"kty": "EC", "use": "sig", "kid": "azZQQ2FEQjh3QnVZWVdrbHJkMEZSaWR6aVJ0LTBjeUFfeWRlbTRrRFZ5VQ", "crv": "P-256", "x": "2ADe18caWWGp6hpRbfa9HqQHDFNpid9xUmR56Wzm_wc", "y": "HnD_8QBanz4Y-UF8mKQFZXfqkGkXUSm34mLsdDKtSyk"}, {"kty": "RSA", "use": "sig", "kid": "SHEyYWcwNVk0LTdROTZzZ2FUWndIVXdack0xWUM5SEpwcS03dVUxWU4zRQ", "n": "rRz52ddyP9Y2ezSlRsnkt-sjXfV_Ii7vOFX-cStLE3IUlVeSJGEe_kAASLr2r3BE2unjntaxj67NP8D95h_rzG1SpCklTEn-aTe3FOwNyTzUH_oiDVeRoEcf04Y43ciRGYRB5PhI6ii-2lYuig6hyUr776Qxiu6-0zw-M_ay2MgGSy5CEj55dDSvcUyxStUObxGpPWnEvybO1vnE7iJEWGNe0L5uPe5nLidOiR-JwjxSWEx1xZYtIjxaf2Ulu-qu4hwgwBUQdx4bNZyBfljKj55skWuHqPMG3xMjnedQC6Ms5bR3rIkbBpvmgI3kJK-4CZikM6ruyLo94-Lk19aYQw", "e": "AQAB"}]}

tests/pub_iss.jwks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "EC", "use": "sig", "kid": "SmdKMlVGcG1zMnprdDdXZGpGWEczdHhlZVpGbkx1THpPdUY4d0w4bnZkSQ", "crv": "P-256", "x": "tRHJYm0fsOi0icpGEb33qiDVgt68ltMoYSWdLGhDGz4", "y": "fRpX0i6p5Jigf5I0qwW34PyStosMShwWAWS8x_w5o7E"}, {"kty": "RSA", "use": "sig", "kid": "R0FsaFdqREFaUFp1c0MwbUpsbHVSZ200blBJZWJVMTUtNGsyVlBmdHk5UQ", "e": "AQAB", "n": "2ilgsKVqF92KfhwmosSVeZOaDgb3RF1mbg-pqkmLO6YpOO06LF4V4angF-GhP-ysAm2E75aSIU4tnHVThFlcxTgKFqjYKJQXyVzTVK2r-L2IbvFPaDtvoU6WteybpMlIUVk2po3cFDGObCWYKCm7CUOLlwH0uOpui66P9VSCqdKVKbJRAQBvTSbP10KWPxulfqjWGJtHO5fY7-JVWwOBkG-eHSJIT_uaoPjyvKCZjknq04bLUV9qP78KRQpRyYijBN60w2v8F79baN9CN10TIEjjWKGz0uX0M_YYQzTUoSY5l5ka9RkL3wT4o2iQ1t5nHphX6aA-gqwgCQmi-nvjaw"}]}
1+
{"keys": [{"kty": "EC", "use": "sig", "kid": "SmdKMlVGcG1zMnprdDdXZGpGWEczdHhlZVpGbkx1THpPdUY4d0w4bnZkSQ", "crv": "P-256", "x": "tRHJYm0fsOi0icpGEb33qiDVgt68ltMoYSWdLGhDGz4", "y": "fRpX0i6p5Jigf5I0qwW34PyStosMShwWAWS8x_w5o7E"}, {"kty": "RSA", "use": "sig", "kid": "R0FsaFdqREFaUFp1c0MwbUpsbHVSZ200blBJZWJVMTUtNGsyVlBmdHk5UQ", "n": "2ilgsKVqF92KfhwmosSVeZOaDgb3RF1mbg-pqkmLO6YpOO06LF4V4angF-GhP-ysAm2E75aSIU4tnHVThFlcxTgKFqjYKJQXyVzTVK2r-L2IbvFPaDtvoU6WteybpMlIUVk2po3cFDGObCWYKCm7CUOLlwH0uOpui66P9VSCqdKVKbJRAQBvTSbP10KWPxulfqjWGJtHO5fY7-JVWwOBkG-eHSJIT_uaoPjyvKCZjknq04bLUV9qP78KRQpRyYijBN60w2v8F79baN9CN10TIEjjWKGz0uX0M_YYQzTUoSY5l5ka9RkL3wT4o2iQ1t5nHphX6aA-gqwgCQmi-nvjaw", "e": "AQAB"}]}

tests/static/jwks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "RSA", "use": "sig", "kid": "YnNESFhyQjloMnYzV2VqRGR2a3VCblFLX2h4VGl3TDVlY3FUNkViUE90bw", "e": "AQAB", "n": "2iMaDALTQolz4UaT--GhjriLMyNbrDGlIXxSmgRh17Cm3cuHiyPOIQv1pjZVg4ATU1aafxmFyTfrmtf56tPuJ8yqcNNZC8XadYPAw7PTW9g8GJgLtC8GURJ9GQZD6FYIE6YCou8fYo6yd4b99y2y_vsl06cm9xQnstfp6eyMkcgQyrmdmlbyeuXwvcxsxtGX61MTJtCp4VELmDctJiYP_bD7HNRPV7uqXDMNmWSY0TYL-tg0As4y8-w3wSwmtcfWhnQEraFT0-m4hBpEWHlouuFNXRQIrXbamKxeh6kJNO0wJN8fZ4Ovygf8sE4kEwBPfWO59wxDF7camTpDUqg29Q"}, {"kty": "EC", "use": "sig", "kid": "aWhtalRSTDZmNmRTd1ZDNWZmY3ZGMTNqM1dnLVA2RjQyMi1CNGdOSUNKVQ", "crv": "P-256", "x": "Ww5XVT3CxYN88BpJDZGodRiar0qr8UvPFaRoqzyD1Io", "y": "w23EDFAvwe03NjL5NKtUXwxuVMFmEn3ecJOPbljiDkg"}]}
1+
{"keys": [{"kty": "RSA", "use": "sig", "kid": "YnNESFhyQjloMnYzV2VqRGR2a3VCblFLX2h4VGl3TDVlY3FUNkViUE90bw", "n": "2iMaDALTQolz4UaT--GhjriLMyNbrDGlIXxSmgRh17Cm3cuHiyPOIQv1pjZVg4ATU1aafxmFyTfrmtf56tPuJ8yqcNNZC8XadYPAw7PTW9g8GJgLtC8GURJ9GQZD6FYIE6YCou8fYo6yd4b99y2y_vsl06cm9xQnstfp6eyMkcgQyrmdmlbyeuXwvcxsxtGX61MTJtCp4VELmDctJiYP_bD7HNRPV7uqXDMNmWSY0TYL-tg0As4y8-w3wSwmtcfWhnQEraFT0-m4hBpEWHlouuFNXRQIrXbamKxeh6kJNO0wJN8fZ4Ovygf8sE4kEwBPfWO59wxDF7camTpDUqg29Q", "e": "AQAB"}, {"kty": "EC", "use": "sig", "kid": "aWhtalRSTDZmNmRTd1ZDNWZmY3ZGMTNqM1dnLVA2RjQyMi1CNGdOSUNKVQ", "crv": "P-256", "x": "Ww5XVT3CxYN88BpJDZGodRiar0qr8UvPFaRoqzyD1Io", "y": "w23EDFAvwe03NjL5NKtUXwxuVMFmEn3ecJOPbljiDkg"}]}

tests/test_server_00a_client_configure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
],
3535
"policy": {
3636
"urn:ietf:params:oauth:token-type:access_token": {
37-
"callable": "/path/to/callable",
37+
"function": "/path/to/function",
3838
"kwargs": {"audience": ["https://example.com"], "scopes": ["openid"]},
3939
},
4040
"urn:ietf:params:oauth:token-type:refresh_token": {
41-
"callable": "/path/to/callable",
41+
"function": "/path/to/function",
4242
"kwargs": {"resource": ["https://example.com"], "scopes": ["openid"]},
4343
},
44-
"": {"callable": "/path/to/callable", "kwargs": {"scopes": ["openid"]}},
44+
"": {"function": "/path/to/function", "kwargs": {"scopes": ["openid"]}},
4545
},
4646
},
4747
},

tests/test_server_24_oauth2_resource_indicators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def get_cookie_value(cookie=None, name=None):
328328
"request_uri_parameter_supported": True,
329329
"resource_indicators": {
330330
"policy": {
331-
"callable": validate_authorization_resource_indicators_policy,
331+
"function": validate_authorization_resource_indicators_policy,
332332
"kwargs": {
333333
"resource_servers_per_client": {
334334
"client_1": ["client_1", "client_2"],
@@ -350,7 +350,7 @@ def get_cookie_value(cookie=None, name=None):
350350
],
351351
"resource_indicators": {
352352
"policy": {
353-
"callable": validate_token_resource_indicators_policy,
353+
"function": validate_token_resource_indicators_policy,
354354
"kwargs": {
355355
"resource_servers_per_client": {
356356
"client_1": ["client_2", "client_3"]
@@ -551,7 +551,7 @@ def test_authorization_code_req_per_client(self, create_endpoint_ri_disabled):
551551
endpoint_context.cdb["client_1"]["resource_indicators"] = {
552552
"authorization_code": {
553553
"policy": {
554-
"callable": validate_authorization_resource_indicators_policy,
554+
"function": validate_authorization_resource_indicators_policy,
555555
"kwargs": {
556556
"resource_servers_per_client":["client_3"]
557557
},

0 commit comments

Comments
 (0)