def authenticate(self, req, resp):
"""
Implements the authentication logic.
:param req: Request instance that will be passed through.
:type req: falcon.Request
:param resp: Response instance that will be passed through.
:type resp: falcon.Response
:raises: falcon.HTTPForbidden
"""
user, passwd = self._decode_basic_auth(req)
if user is not None and passwd is not None:
if user in self._data.keys():
self.logger.debug('User {0} found in datastore.'.format(user))
if self.check_authentication(user, passwd):
return # Authentication is good
# Forbid by default
raise falcon.HTTPForbidden('Forbidden', 'Forbidden')
评论列表
文章目录