fix(api): fixed internal server error being generated from invalid UTF-8 encoded X-API-KEY

This commit is contained in:
Nigel Kukard 2023-03-22 01:27:52 +00:00
parent 419bf35892
commit a954800869

View File

@ -460,10 +460,8 @@ def apikey_auth(f):
if auth_header: if auth_header:
try: try:
apikey_val = str(base64.b64decode(auth_header), 'utf-8') apikey_val = str(base64.b64decode(auth_header), 'utf-8')
except binascii.Error as e: except (binascii.Error, UnicodeDecodeError) as e:
current_app.logger.error( current_app.logger.error('Invalid base64-encoded X-API-KEY. Error {0}'.format(e))
'Invalid base64-encoded of credential. Error {0}'.format(
e))
abort(401) abort(401)
except TypeError as e: except TypeError as e:
current_app.logger.error('Error: {0}'.format(e)) current_app.logger.error('Error: {0}'.format(e))