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

Commit 90c3a08

Browse files
committed
Added 2 new parameters to gather_verify_arguments. Allows for extended functionality.
1 parent 9ec3b08 commit 90c3a08

File tree

6 files changed

+30
-39
lines changed

6 files changed

+30
-39
lines changed

src/oidcrp/oidc/access_token.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import logging
22
from typing import Optional
3+
from typing import Union
34

45
from oidcmsg import oidc
6+
from oidcmsg.message import Message
57
from oidcmsg.oidc import verified_claim_name
68
from oidcmsg.time_util import time_sans_frac
79

@@ -26,7 +28,9 @@ def __init__(self,
2628
access_token.AccessToken.__init__(self, client_get,
2729
client_authn_factory=client_authn_factory, conf=conf)
2830

29-
def gather_verify_arguments(self):
31+
def gather_verify_arguments(self,
32+
response: Optional[Union[dict, Message]] = None,
33+
behaviour_args: Optional[dict] = None):
3034
"""
3135
Need to add some information before running verify()
3236

src/oidcrp/oidc/authorization.py

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import logging
2+
from typing import Optional
3+
from typing import Union
24

35
from oidcmsg import oauth2
46
from oidcmsg import oidc
57
from oidcmsg.exception import MissingRequiredAttribute
8+
from oidcmsg.message import Message
69
from oidcmsg.oidc import make_openid_request
710
from oidcmsg.oidc import verified_claim_name
811
from oidcmsg.time_util import time_sans_frac
912
from oidcmsg.time_util import utc_time_sans_frac
1013

11-
from oidcrp.exception import ParameterError
1214
from oidcrp.oauth2 import authorization
1315
from oidcrp.oauth2.utils import pre_construct_pick_redirect_uri
1416
from oidcrp.oidc import IDT2REG
@@ -239,34 +241,9 @@ def oidc_post_construct(self, req, **kwargs):
239241

240242
return req
241243

242-
# def post_parse_response(self, response, **kwargs):
243-
# """
244-
# Add scope claim to response, from the request, if not present in the
245-
# response
246-
#
247-
# :param response: The response
248-
# :param kwargs: Extra Keyword arguments
249-
# :return: A possibly augmented response
250-
# """
251-
#
252-
# authorization.Authorization.parse_response(self, response, **kwargs)
253-
#
254-
# if "id_token" not in response:
255-
# try:
256-
# _key = kwargs['state']
257-
# except KeyError:
258-
# pass
259-
# else:
260-
# if _key:
261-
# item = self.client_get("service_context").state.get_item(oauth2.AuthorizationRequest,
262-
# 'auth_request', _key)
263-
# try:
264-
# response["scope"] = item["scope"]
265-
# except KeyError:
266-
# pass
267-
# return response
268-
269-
def gather_verify_arguments(self):
244+
def gather_verify_arguments(self,
245+
response: Optional[Union[dict, Message]] = None,
246+
behaviour_args: Optional[dict] = None):
270247
"""
271248
Need to add some information before running verify()
272249

src/oidcrp/oidc/userinfo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
from typing import Optional
3+
from typing import Union
24

35
from oidcmsg import oidc
46
from oidcmsg.exception import MissingSigningKey
@@ -112,7 +114,9 @@ def post_parse_response(self, response, **kwargs):
112114
_state_interface.store_item(response, 'user_info', kwargs['state'])
113115
return response
114116

115-
def gather_verify_arguments(self):
117+
def gather_verify_arguments(self,
118+
response: Optional[Union[dict, Message]] = None,
119+
behaviour_args: Optional[dict] = None):
116120
"""
117121
Need to add some information before running verify()
118122

src/oidcrp/service.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self,
9090
self.construct_extra_headers = []
9191
self.post_parse_process = []
9292

93-
def gather_request_args(self, **kwargs):
93+
def gather_request_args(self,**kwargs):
9494
"""
9595
Go through the attributes that the message class can contain and
9696
add values if they are missing but exists in the client info or
@@ -444,7 +444,9 @@ def post_parse_response(self, response, **kwargs):
444444
"""
445445
return response
446446

447-
def gather_verify_arguments(self):
447+
def gather_verify_arguments(self,
448+
response: Optional[Union[dict, Message]] = None,
449+
behaviour_args: Optional[dict] = None):
448450
"""
449451
Need to add some information before running verify()
450452
@@ -501,7 +503,11 @@ def _do_response(self, info, sformat, **kwargs):
501503
raise
502504
return resp
503505

504-
def parse_response(self, info, sformat="", state="", **kwargs):
506+
def parse_response(self, info,
507+
sformat: Optional[str] = "",
508+
state: Optional[str] = "",
509+
behaviour_args: Optional[dict] = None,
510+
**kwargs):
505511
"""
506512
This the start of a pipeline that will:
507513
@@ -513,8 +519,8 @@ def parse_response(self, info, sformat="", state="", **kwargs):
513519
3 runs the do_post_parse_response method iff the response was not
514520
an error response.
515521
516-
:param info: The response, can be either in a JSON or an urlencoded
517-
format
522+
:param behaviour_args:
523+
:param info: The response, can be either in a JSON or an urlencoded format
518524
:param sformat: Which serialization that was used
519525
:param state: The state
520526
:param kwargs: Extra key word arguments
@@ -554,7 +560,7 @@ def parse_response(self, info, sformat="", state="", **kwargs):
554560
if is_error_message(resp):
555561
LOGGER.debug('Error response: %s', resp)
556562
else:
557-
vargs = self.gather_verify_arguments()
563+
vargs = self.gather_verify_arguments(response=resp, behaviour_args=behaviour_args)
558564
LOGGER.debug("Verify response with %s", vargs)
559565
try:
560566
# verify the message. If something is wrong an exception is thrown

tests/pub_client.jwks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "RSA", "use": "sig", "kid": "SUswNi1MRFlDT0Y2YjU1Z1RfQlo2S3dEa3FTTkV3LThFcnhDTHF5elk2VQ", "e": "AQAB", "n": "0UkUx2ewKyc-XJ1o0ToyGjws_JybAMZj2oYjsPyyvQ_T5dhZ2VmRRRkhsaVJ2xE_GGc7mSG0IjmGFyXp5y0w4mJBcsAEE5-8eBTvQdYIryjW74r3jt6Fi4Hlm1yFMTie3apv8mw79BUj-jT0kh3_m-FiKKUvLsq45DcLtTJ4cx7Ize37dl1sFSpQcoYMk7eiUEM8fiNboiVwvBYNAWVMkUM-LnVUPm3UjvKp0LihYEkZFWOxmuQmj2x25SFUkjus38ERrRqJQBZduxdBHFrWtWg8yOA53BkMU0FFg_r0H3ctl-5GaKw-BWlogU4qXnsq85xy0EoenRk7FPV8g_ulJw"}, {"kty": "EC", "use": "sig", "kid": "NC1pdGRQN002bWM3bk1xX2R0SktscElqbFdtN29ITDV2WVd2b0hOYzREVQ", "crv": "P-256", "x": "kK7Qp1woSerI7rUOAwW_4sU6ZmwV3wwXKX3VU-v2fMI", "y": "iPWd_Pjq6EjxYy08KNFZ3PxhEwgWHgAQTTknlKMKJA0"}]}
1+
{"keys": [{"kty": "RSA", "use": "sig", "kid": "SUswNi1MRFlDT0Y2YjU1Z1RfQlo2S3dEa3FTTkV3LThFcnhDTHF5elk2VQ", "n": "0UkUx2ewKyc-XJ1o0ToyGjws_JybAMZj2oYjsPyyvQ_T5dhZ2VmRRRkhsaVJ2xE_GGc7mSG0IjmGFyXp5y0w4mJBcsAEE5-8eBTvQdYIryjW74r3jt6Fi4Hlm1yFMTie3apv8mw79BUj-jT0kh3_m-FiKKUvLsq45DcLtTJ4cx7Ize37dl1sFSpQcoYMk7eiUEM8fiNboiVwvBYNAWVMkUM-LnVUPm3UjvKp0LihYEkZFWOxmuQmj2x25SFUkjus38ERrRqJQBZduxdBHFrWtWg8yOA53BkMU0FFg_r0H3ctl-5GaKw-BWlogU4qXnsq85xy0EoenRk7FPV8g_ulJw", "e": "AQAB"}, {"kty": "EC", "use": "sig", "kid": "NC1pdGRQN002bWM3bk1xX2R0SktscElqbFdtN29ITDV2WVd2b0hOYzREVQ", "crv": "P-256", "x": "kK7Qp1woSerI7rUOAwW_4sU6ZmwV3wwXKX3VU-v2fMI", "y": "iPWd_Pjq6EjxYy08KNFZ3PxhEwgWHgAQTTknlKMKJA0"}]}

tests/request123456.jwt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJSUzI1NiIsImtpZCI6IlNVc3dOaTFNUkZsRFQwWTJZalUxWjFSZlFsbzJTM2RFYTNGVFRrVjNMVGhGY25oRFRIRjVlbGsyVlEifQ.eyJyZXNwb25zZV90eXBlIjogImNvZGUiLCAic3RhdGUiOiAic3RhdGUiLCAicmVkaX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