def authenticate(self, login, password): token = ModuleManager().authenticate(login, password) if token: # set authentication cookie self.setCookie('Token', token) return True return False
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")
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