예제 #1
0
 def prepare(self, request, response):
     self.db = configuration.get_db()
     try:
         user, password = basic_authenticate.decode(request)
         self.user = self.get_named_document('account', user)
         if self.user.get('password') != utils.hexdigest(password):
             raise ValueError
     except ValueError:
         raise HTTP_UNAUTHORIZED_BASIC_CHALLENGE(realm='slog')
     self.user_agent = request.environ.get('HTTP_USER_AGENT')
예제 #2
0
파일: resource.py 프로젝트: pekrau/slog
 def prepare(self, request, response):
     """Prepare for request processing:
     1) Get the database connection.
     2) Get account authentication.
     3) Get user agent information.
     4) Get the explicit accept types for content negotiation.
     """
     self.db = utils.get_db()
     try:
         user, password = basic_authenticate.decode(request)
         self.user = self.get_entity_document('account', user)
         if self.user.get('password') != utils.get_hexdigest(password):
             raise ValueError
     except ValueError:
         raise HTTP_UNAUTHORIZED_BASIC_CHALLENGE(realm='slog')
     self.user_agent = request.environ.get('HTTP_USER_AGENT')
     self.accept = set()
     for item in request.headers.get('Accept', 'text/html').split(','):
         self.accept.add(item.strip().split(';')[0].strip())