def _decode_bearer_auth(self, req):
"""
Decodes basic auth from the header.
:param req: Request instance that will be passed through.
:type req: falcon.Request
:returns: token or None if empty.
:rtype: str
"""
self.logger.debug('header: {}'.format(req.auth))
if req.auth is not None:
if req.auth.lower().startswith('bearer '):
decoded = req.auth[7:]
self.logger.debug('Token given: {0}'.format(decoded))
return decoded
else:
self.logger.debug(
'Did not find bearer in the Authorization '
'header from {0}.'.format(req.remote_addr))
# Default meaning no user or password
self.logger.debug('Authentication for {0} failed.'.format(
req.remote_addr))
return None
评论列表
文章目录