Skip to content

Commit

Permalink
fix: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvatore Laiso committed Nov 6, 2023
1 parent 8ebcaff commit b3c6eef
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pyeudiw/satosa/dpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

from pyeudiw.jwt.utils import unpad_jwt_header, unpad_jwt_payload
from pyeudiw.oauth2.dpop import DPoPVerifier
from pyeudiw.openid4vp.schemas.wallet_instance_attestation import WalletInstanceAttestationPayload
from pyeudiw.openid4vp.schemas.wallet_instance_attestation import WalletInstanceAttestationPayload, \
WalletInstanceAttestationHeader
from pyeudiw.satosa.response import JsonResponse

import satosa.logging_util as lu
from satosa.context import Context

logger = logging.getLogger(__name__)

Expand All @@ -33,6 +36,15 @@ def _request_endpoint_dpop(self, context, *args) -> Union[JsonResponse, None]:
)
)

try:
WalletInstanceAttestationHeader(**_head)
except Exception as e:
self._log(
context,
level='warning',
message=f"[FOUND WIA] Invalid Headers: {_head}! \nValidation error: {e}"
)

try:
self._validate_trust(context, dpop_jws)
except Exception as e:
Expand Down Expand Up @@ -84,3 +96,12 @@ def _request_endpoint_dpop(self, context, *args) -> Union[JsonResponse, None]:
"a default set of capabilities and a low security level are applied."
)
self._log(context, level='warning', message=_msg)

def _log(self, context: Context, level: str, message: str) -> None:
log_level = getattr(logger, level)
log_level(
lu.LOG_FMT.format(
id=lu.get_session_id(context.state),
message=message
)
)

0 comments on commit b3c6eef

Please sign in to comment.