Fix auth header exception handling to avoid 500.
Signed-off-by: dliu5 <david.liu@windriver.com>
Change-Id: I7fb0d11584f6e575ba891a51bebd7631faef7505
logger.info(__name__ + 'authentication middleware')
req = Request(environ, populate_request=True, shallow=True)
try:
- auth_header = req.headers['Authorization']
-
+ auth_header = req.headers.get('Authorization', None)
if auth_header:
auth_token = auth_header.split(" ")[1]
return
logger.error('Notify alarm Response code is: {}'.format(status))
except ssl.SSLCertVerificationError as e:
- logger.info(
- 'Notify alarm post data with trusted ca failed: {}'.format(e))
+ logger.debug(
+ 'Notify alarm try to post data with trusted ca \
+ failed: {}'.format(e))
if 'self signed' in str(e):
conn = get_https_conn_selfsigned(o.netloc)
try:
return
logger.error('Notify Response code is: {}'.format(status))
except ssl.SSLCertVerificationError as e:
- logger.info('Notify post data with trusted ca failed: {}'.format(e))
+ logger.debug(
+ 'Notify try to post data with trusted ca failed: {}'.format(e))
if 'self signed' in str(e):
conn = get_https_conn_selfsigned(o.netloc)
try:
try:
return post_data(conn, o.path, callback_data)
except ssl.SSLCertVerificationError as e:
- logger.info('Register to smo with trusted ca failed: {}'.format(e))
+ logger.debug('Try to register to smo with \
+ trusted ca failed: {}'.format(e))
if 'self signed' in str(e):
conn = get_https_conn_selfsigned(o.netloc)
try: