Ejemplo n.º 1
0
 def authenticate(self, login, password):
     token = ModuleManager().authenticate(login, password)
     if token:
         # set authentication cookie
         self.setCookie('Token', token)
         return True
     return False
Ejemplo n.º 2
0
    def _dispatch(self, method, params):
        self.cookies = []

        if method == 'authenticate':
            return self.authenticate(*params)
        elif method in UNAUTHENTICATED_METHODS or self.check_token():
            try:
                return ModuleManager()._dispatch(method, params)
            except Exception:
                logger.exception("Error while calling ModuleManager.%s" % method)
                raise
        else:
            raise Exception(u"Authentication failed")
Ejemplo n.º 3
0
 def check_token(self):
     if self.headers.has_key('Token'):
         # handle cookie based authentication
         token = self.headers.get('Token')
         return ModuleManager().check_token(token)
     return False