Lots of small NPE and other exception fixes
This commit is contained in:
parent
511ee12a58
commit
e8ad01cb41
5 changed files with 22 additions and 4 deletions
|
@ -135,8 +135,15 @@ def process_token(auth):
|
|||
logger.warning('Invalid token format: %s' % auth)
|
||||
abort(401, message='Invalid token format: %(auth)s', issue='invalid-auth-token', auth=auth)
|
||||
|
||||
token_vals = {val[0]: val[1] for val in
|
||||
def safe_get(lst, index, default_value):
|
||||
try:
|
||||
return lst[index]
|
||||
except IndexError:
|
||||
return default_value
|
||||
|
||||
token_vals = {val[0]: safe_get(val, 1, '') for val in
|
||||
(detail.split('=') for detail in token_details)}
|
||||
|
||||
if 'signature' not in token_vals:
|
||||
logger.warning('Token does not contain signature: %s' % auth)
|
||||
abort(401, message='Token does not contain a valid signature: %(auth)s',
|
||||
|
|
Reference in a new issue