Skip to content

Commit

Permalink
applied some suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zicchio committed Sep 25, 2024
1 parent ce51de3 commit 5fa54ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyeudiw/satosa/default/response_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from pyeudiw.openid4vp.vp_mock import MockVpVerifier
from pyeudiw.openid4vp.vp_sd_jwt import VpSdJwt
from pyeudiw.openid4vp.vp_sd_jwt_kb import VpVcSdJwtKbVerifier, VpVerifier
from pyeudiw.satosa.exceptions import AuthorizeUnmatchedResponse, BadRequestError, FinalizedSessionError, InvalidInternalStateError, NotTrustedFederationError, HTTPError
from pyeudiw.satosa.exceptions import (AuthorizeUnmatchedResponse, BadRequestError, FinalizedSessionError,
InvalidInternalStateError, NotTrustedFederationError, HTTPError)
from pyeudiw.satosa.interfaces.response_handler import ResponseHandlerInterface
from pyeudiw.satosa.utils.response import JsonResponse
from pyeudiw.satosa.utils.trust import BackendTrust
Expand Down Expand Up @@ -118,14 +119,14 @@ def _retrieve_session_and_nonce_from_state(self, state: str) -> tuple[dict, str]
except Exception as err:
raise AuthorizeUnmatchedResponse(f"unable to find document-session associated to state {state}", err)

if request_session is None:
if not request_session:
raise InvalidInternalStateError(f"unable to find document-session associated to state {state}")

if request_session.get("finalized", True):
raise FinalizedSessionError(f"cannot accept response: session for state {state} corrupted or already finalized")

nonce = request_session.get("nonce", None)
if nonce is None:
if not nonce:
raise InvalidInternalStateError(f"unnable to find nonce in session associated to state {state}")
return request_session, nonce

Expand Down Expand Up @@ -220,6 +221,7 @@ def response_endpoint(self, context: Context, *args: tuple) -> Redirect | JsonRe
return self._handle_400(context, f"unable to process vp token with typ={unrecognized_typ}")
if verifier is None:
return self._handle_500(context, "invalid state", Exception("invalid state"))
# TODO: revocation check here
# verifier.check_revocation_status()
try:
verifier.verify()
Expand All @@ -228,7 +230,6 @@ def response_endpoint(self, context: Context, *args: tuple) -> Redirect | JsonRe
claims = verifier.parse_digital_credential()
attributes_by_issuer[iss] = claims
self._log_debug(context, f"disclosed claims {claims} from issuer {iss}")
pass
all_attributes = self._extract_all_user_attributes(attributes_by_issuer)
iss_list_serialized = ";".join(credential_issuers) # marshaling is whatever
internal_resp = self._translate_response(all_attributes, iss_list_serialized, context)
Expand Down

0 comments on commit 5fa54ed

Please sign in to comment.