def make_token_soledad_app(state): application = SoledadApp(state) def _verify_authentication_data(uuid, auth_data): if uuid.startswith('user-') and auth_data == 'auth-token': return True return False # we test for action authorization in leap.soledad.common.tests.test_server def _verify_authorization(uuid, environ): return True application._verify_authentication_data = _verify_authentication_data application._verify_authorization = _verify_authorization return application
def make_soledad_server_thread(couch_port): state = CouchServerState('http://127.0.0.1:%d' % couch_port, 'shared', 'tokens') application = GzipMiddleware(SoledadTokenAuthMiddleware(SoledadApp(state))) server = make_server('', 0, application) t = SoledadServerThread(server) return t
def make_soledad_app(state): return SoledadApp(state)
def get_sync_resource(pool): conf = get_config() state = _get_couch_state(conf) app = SoledadApp(state) wsgi_app = GzipMiddleware(app) return WSGIResource(reactor, pool, wsgi_app)
from leap.soledad.common.log import getLogger from twisted.logger import Logger log = Logger() __all__ = ['init_couch_state', 'get_sync_resource'] def _get_couch_state(conf): state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd'], check_schema_versions=True) SoledadBackend.BATCH_SUPPORT = conf.get('batching', False) return state _app = SoledadApp(None) # delay state init wsgi_application = GzipMiddleware(_app) # During its initialization, the couch state verifies if all user databases # contain a config document with the correct couch schema version stored, and # will log an error and raise an exception if that is not the case. # # If this verification made too early (i.e. before the reactor has started and # the twistd web logging facilities have been setup), the logging will not # work. Because of that, we delay couch state initialization until the reactor # is running. def init_couch_state(conf): try: _app.state = _get_couch_state(conf)