Skip to content

Commit 9e1fb5f

Browse files
authored
Merge pull request #420 from italia/fix/direct_post_psub
fix: handling of presentation sub in direct post
2 parents dff85c4 + 7e00724 commit 9e1fb5f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pyeudiw/openid4vp/authorization_response.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from typing import TypeVar
23
import cryptojwt.jwe.exception
34
import satosa.context
@@ -98,7 +99,10 @@ def parse_and_validate(
9899
if (state := resp_data.get("state", None)):
99100
d["state"] = state
100101
if (presentation_submission := resp_data["presentation_submission"]):
101-
d["presentation_submission"] = presentation_submission
102+
if isinstance(presentation_submission, dict):
103+
d["presentation_submission"] = presentation_submission
104+
else:
105+
d["presentation_submission"] = json.loads(presentation_submission)
102106
return AuthorizeResponsePayload(**d)
103107
except Exception as e:
104108
raise AuthRespParsingException(

pyeudiw/satosa/default/request_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def request_endpoint(self, context: Context, *args) -> Response:
103103
status="200",
104104
content=RequestHandler._RESP_CONTENT_TYPE,
105105
)
106-
except JWSSigningError as e500:
106+
except Exception as e500:
107107
return self._handle_500(
108108
context,
109109
"internal error: error while processing the request object",

pyeudiw/tests/openid4vp/test_authorization_response.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import pytest
23
import satosa.context
34

@@ -48,7 +49,7 @@ def test_direct_post_parser_good_case():
4849
ctx.request = {
4950
"vp_token": vp_token,
5051
"state": state,
51-
"presentation_submission": presentation_submission,
52+
"presentation_submission": json.dumps(presentation_submission),
5253
}
5354

5455
resp = parser.parse_and_validate(ctx)
@@ -87,7 +88,7 @@ def test_direct_post_response_bad_parse_case():
8788
ctx.qs_params = {
8889
"vp_token": vp_token,
8990
"state": state,
90-
"presentation_submission": presentation_submission,
91+
"presentation_submission": json.dumps(presentation_submission),
9192
}
9293

9394
try:

0 commit comments

Comments
 (0)