Skip to content

chore: JWT warnings on failed JWT ops #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cryptojwt/jws/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ def verify_compact_verbose(self, jws=None, keys=None, allow_none=False, sigalg=N
try:
if not verifier.verify(jwt.sign_input(), jwt.signature(), _key):
continue
except (BadSignature, IndexError):
pass
except (BadSignature, IndexError) as err:
logger.warning(f'BadSignature caught with {jwt}: "{err}"')
except (ValueError, TypeError) as err:
logger.warning('Exception "{}" caught'.format(err))
logger.warning(f'Exception with {jwt.headers}: "{err}"')
else:
logger.debug("Verified message using key with kid=%s" % key.kid)
logger.debug(f"Verified message using key with kid={key.kid}")
self.msg = jwt.payload()
self.key = key
self._protected_headers = jwt.headers.copy()
Expand Down
8 changes: 3 additions & 5 deletions src/cryptojwt/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,9 @@ def unpack(self, token):
if self.msg_cls:
_msg_cls = self.msg_cls
else:
try:
# try to find a issuer specific message class
_msg_cls = self.iss2msg_cls[_info["iss"]]
except KeyError:
_msg_cls = None
_msg_cls = self.iss2msg_cls.get(_info["iss"], None)
if not _msg_cls:
LOGGER.debug(f"both msg_cls and iss2msg are None for the issuer {_info['iss']}")

if _msg_cls:
vp_args = {"skew": self.skew}
Expand Down