Skip to content

Commit

Permalink
Merge pull request #27 from peppelinux/master
Browse files Browse the repository at this point in the history
replaced try/except with get
  • Loading branch information
rohe authored Feb 24, 2020
2 parents e38f197 + 0c690b3 commit 81fa5aa
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/cryptojwt/key_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,36 +579,18 @@ def get_jwt_verify_keys(self, jwt, **kwargs):
:return: list of usable keys
"""

try:
allow_missing_kid = kwargs['allow_missing_kid']
except KeyError:
allow_missing_kid = False
allow_missing_kid = kwargs.get('allow_missing_kid', False)

try:
_key_type = ''
if jwt.headers.get('alg'):
_key_type = jws_alg2keytype(jwt.headers['alg'])
except KeyError:
_key_type = ''

try:
_kid = jwt.headers['kid']
except KeyError:
logger.info('Missing kid')
_kid = ''

try:
nki = kwargs['no_kid_issuer']
except KeyError:
nki = {}
_kid = jwt.headers.get('kid', "")
nki = kwargs.get('no_kid_issuer', {})

_payload = jwt.payload()

try:
_iss = _payload['iss']
except KeyError:
try:
_iss = kwargs['iss']
except KeyError:
_iss = ''
_iss = _payload.get('iss') or kwargs.get('iss') or ""

if _iss:
# First extend the key jar iff allowed
Expand Down

0 comments on commit 81fa5aa

Please sign in to comment.