From 36f3daf7ae3a76711cdc319a97a835047cd22605 Mon Sep 17 00:00:00 2001 From: Christoph Kluenter Date: Thu, 7 Jul 2016 09:15:52 +0200 Subject: [pkg] remove pixelated from requirements-latest.pip modifying original PR [0] by cristoph to account for the recent vendoring of l2db code, which means we no longer depend on u1db/dirspec. I expect the whole mess about the venv setup to be further simplified pretty soon, since we are going to merge most of the leap.* packages into a couple of repos. [0] https://github.com/leapcode/soledad/pull/327 --- server/pkg/requirements-latest.pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/pkg/requirements-latest.pip b/server/pkg/requirements-latest.pip index 46a7ccba..d32e1ffa 100644 --- a/server/pkg/requirements-latest.pip +++ b/server/pkg/requirements-latest.pip @@ -1,5 +1,5 @@ --index-url https://pypi.python.org/simple/ --e 'git+https://github.com/pixelated-project/leap_pycommon.git@develop#egg=leap.common' +-e 'git+https://github.com/leapcode/leap_pycommon.git@develop#egg=leap.common' -e '../common' -e . -- cgit v1.2.3 From c7b464077215425759ab402fb2314f4e8f9acd7e Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 23 Jul 2016 17:11:53 +0200 Subject: [test] remove traces of design docs from couch tests --- server/pkg/create-user-db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/pkg/create-user-db b/server/pkg/create-user-db index 5e48d4de..b955b4c3 100755 --- a/server/pkg/create-user-db +++ b/server/pkg/create-user-db @@ -80,7 +80,7 @@ def ensure_database(dbname): url = url_for_db(dbname) db_security = CONF['database-security'] db = CouchDatabase.open_database(url=url, create=True, - replica_uid=None, ensure_ddocs=True, + replica_uid=None, database_security=db_security) print ('success! Ensured that database %s exists, with replica_uid: %s' % (db._dbname, db.replica_uid)) -- cgit v1.2.3 From c8709722223f6c813ad49df09185c316746f9edb Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 8 Aug 2016 13:50:38 -0300 Subject: [pkg] remove version pinning for couchdb and beaker We will not maintain support for older versions of debian as that introduces some unneeded complexity for now. Also, the version pinned for couchdb python library has a bug that makes some requests slow. Because of those, we remove the pinning for now. --- server/pkg/requirements.pip | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/pkg/requirements.pip b/server/pkg/requirements.pip index 2d845f24..e92dfde6 100644 --- a/server/pkg/requirements.pip +++ b/server/pkg/requirements.pip @@ -1,6 +1,5 @@ configparser PyOpenSSL twisted>=12.3.0 -#pinned for wheezy compatibility -Beaker==1.6.3 #wheezy -couchdb==0.8 #wheezy +Beaker +couchdb -- cgit v1.2.3 From 7d2e485d37c2928b7ed773df7f6a5aa98e3396c0 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 9 Aug 2016 15:25:50 -0300 Subject: [feat] log to syslog (#8286) --- server/pkg/soledad-server | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/pkg/soledad-server b/server/pkg/soledad-server index 74ed122e..9dada6a0 100644 --- a/server/pkg/soledad-server +++ b/server/pkg/soledad-server @@ -12,7 +12,6 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin PIDFILE=/var/run/soledad.pid OBJ=leap.soledad.server.application -LOGFILE=/var/log/soledad.log HTTPS_PORT=2424 CONFDIR=/etc/soledad CERT_PATH="${CONFDIR}/soledad-server.pem" @@ -37,7 +36,8 @@ case "${1}" in --exec ${TWISTD_PATH} -- \ --uid=${USER} --gid=${GROUP} \ --pidfile=${PIDFILE} \ - --logfile=${LOGFILE} \ + --syslog \ + --prefix=soledad-server \ web \ --wsgi=${OBJ} \ --port=ssl:${HTTPS_PORT}:privateKey=${PRIVKEY_PATH}:certKey=${CERT_PATH}:sslmethod=${SSL_METHOD} -- cgit v1.2.3 From 47fa0a4554ddf5a81d5da895b00ed8c33526694b Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 6 Sep 2016 10:06:18 -0400 Subject: [style] pep8 --- server/setup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server') diff --git a/server/setup.py b/server/setup.py index b3b26010..a18d0b2d 100644 --- a/server/setup.py +++ b/server/setup.py @@ -122,13 +122,13 @@ requirements = utils.parse_requirements() if utils.is_develop_mode(): print - print ("[WARNING] Skipping leap-specific dependencies " - "because development mode is detected.") - print ("[WARNING] You can install " - "the latest published versions with " - "'pip install -r pkg/requirements-leap.pip'") - print ("[WARNING] Or you can instead do 'python setup.py develop' " - "from the parent folder of each one of them.") + print("[WARNING] Skipping leap-specific dependencies " + "because development mode is detected.") + print("[WARNING] You can install " + "the latest published versions with " + "'pip install -r pkg/requirements-leap.pip'") + print("[WARNING] Or you can instead do 'python setup.py develop' " + "from the parent folder of each one of them.") print else: requirements += utils.parse_requirements( -- cgit v1.2.3 From b7340a962bfeae9af28c4b514d0eb077f41dd832 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 22 Sep 2016 14:44:46 -0300 Subject: [feat] centralize logging and use twisted.logger by default --- server/src/leap/soledad/server/auth.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/src/leap/soledad/server/auth.py b/server/src/leap/soledad/server/auth.py index ecee2d5d..b7186b3b 100644 --- a/server/src/leap/soledad/server/auth.py +++ b/server/src/leap/soledad/server/auth.py @@ -22,13 +22,16 @@ import json from abc import ABCMeta, abstractmethod from routes.mapper import Mapper -from twisted.python import log +from leap.soledad.common.log import getLogger from leap.soledad.common.l2db import DBNAME_CONSTRAINTS, errors as u1db_errors from leap.soledad.common import SHARED_DB_NAME from leap.soledad.common import USER_DB_PREFIX +logger = getLogger(__name__) + + class URLToAuthorization(object): """ Verify if actions can be performed by a user. @@ -378,7 +381,7 @@ class SoledadTokenAuthMiddleware(SoledadAuthMiddleware): try: return self._state.verify_token(uuid, token) except Exception as e: - log.err(e) + logger.error(e) return False def _get_auth_error_string(self): -- cgit v1.2.3 From e13aefd14e82794622613802733713c6226e1d59 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 3 Oct 2016 17:05:36 -0300 Subject: [refactor] move configuration loading to its own module --- server/src/leap/soledad/server/__init__.py | 88 +++++++----------------------- server/src/leap/soledad/server/config.py | 67 +++++++++++++++++++++++ 2 files changed, 86 insertions(+), 69 deletions(-) create mode 100644 server/src/leap/soledad/server/config.py (limited to 'server') diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index 34570b52..97bcf888 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -80,7 +80,6 @@ documents on the shared database is handled by `leap.soledad.server.auth` module. """ -import configparser import urlparse import sys @@ -88,11 +87,10 @@ from leap.soledad.common.l2db.remote import http_app, utils from leap.soledad.server.auth import SoledadTokenAuthMiddleware from leap.soledad.server.gzip_middleware import GzipMiddleware -from leap.soledad.server.sync import ( - SyncResource, - MAX_REQUEST_SIZE, - MAX_ENTRY_SIZE, -) +from leap.soledad.server.sync import SyncResource +from leap.soledad.server.sync import MAX_REQUEST_SIZE +from leap.soledad.server.sync import MAX_ENTRY_SIZE +from soledad.server.config import load_configuration from leap.soledad.common import SHARED_DB_NAME from leap.soledad.common.backend import SoledadBackend @@ -100,6 +98,14 @@ from leap.soledad.common.couch.state import CouchServerState from ._version import get_versions + +__all__ = [ + 'SoledadApp', + 'application', + '__version__', +] + + # ---------------------------------------------------------------------------- # Soledad WSGI application # ---------------------------------------------------------------------------- @@ -249,57 +255,6 @@ class HTTPInvocationByMethodWithBody( http_app.HTTPInvocationByMethodWithBody = HTTPInvocationByMethodWithBody -# ---------------------------------------------------------------------------- -# Auxiliary functions -# ---------------------------------------------------------------------------- -CONFIG_DEFAULTS = { - 'soledad-server': { - 'couch_url': 'http://localhost:5984', - 'create_cmd': None, - 'admin_netrc': '/etc/couchdb/couchdb-admin.netrc', - 'batching': False - }, - 'database-security': { - 'members': ['soledad'], - 'members_roles': [], - 'admins': [], - 'admins_roles': [] - } -} - - -def load_configuration(file_path): - """ - Load server configuration from file. - - @param file_path: The path to the configuration file. - @type file_path: str - - @return: A dictionary with the configuration. - @rtype: dict - """ - defaults = dict(CONFIG_DEFAULTS) - config = configparser.SafeConfigParser() - config.read(file_path) - for section in defaults: - if not config.has_section(section): - continue - for key, value in defaults[section].items(): - if not config.has_option(section, key): - continue - elif type(value) == bool: - defaults[section][key] = config.getboolean(section, key) - elif type(value) == list: - values = config.get(section, key).split(',') - values = [v.strip() for v in values] - defaults[section][key] = values - else: - defaults[section][key] = config.get(section, key) - # TODO: implement basic parsing/sanitization of options comming from - # config file. - return defaults - - # ---------------------------------------------------------------------------- # Run as Twisted WSGI Resource # ---------------------------------------------------------------------------- @@ -317,20 +272,15 @@ def _get_couch_state(): return state -def application(environ, start_response): - """return WSGI application that may be used by `twistd -web`""" - state = _get_couch_state() - application = GzipMiddleware( - SoledadTokenAuthMiddleware(SoledadApp(state))) - return application(environ, start_response) +_couch_state = _get_couch_state() +# a WSGI application that may be used by `twistd -web` +application = GzipMiddleware( + SoledadTokenAuthMiddleware(SoledadApp(_couch_state))) -def debug_local_application_do_not_use(environ, start_response): - """in where we bypass token auth middleware for ease of mind while - debugging in your local environment""" - state = _get_couch_state() - application = SoledadApp(state) - return application(environ, start_response) +# another WSGI application in which we bypass token auth middleware for ease of +# mind while debugging in your local environment +# debug_local_application_do_not_use = SoledadApp(_couch_state) __version__ = get_versions()['version'] diff --git a/server/src/leap/soledad/server/config.py b/server/src/leap/soledad/server/config.py new file mode 100644 index 00000000..4a791cbe --- /dev/null +++ b/server/src/leap/soledad/server/config.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# config.py +# Copyright (C) 2016 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import configparser + + +CONFIG_DEFAULTS = { + 'soledad-server': { + 'couch_url': 'http://localhost:5984', + 'create_cmd': None, + 'admin_netrc': '/etc/couchdb/couchdb-admin.netrc', + 'batching': False + }, + 'database-security': { + 'members': ['soledad'], + 'members_roles': [], + 'admins': [], + 'admins_roles': [] + } +} + + +def load_configuration(file_path): + """ + Load server configuration from file. + + @param file_path: The path to the configuration file. + @type file_path: str + + @return: A dictionary with the configuration. + @rtype: dict + """ + defaults = dict(CONFIG_DEFAULTS) + config = configparser.SafeConfigParser() + config.read(file_path) + for section in defaults: + if not config.has_section(section): + continue + for key, value in defaults[section].items(): + if not config.has_option(section, key): + continue + elif type(value) == bool: + defaults[section][key] = config.getboolean(section, key) + elif type(value) == list: + values = config.get(section, key).split(',') + values = [v.strip() for v in values] + defaults[section][key] = values + else: + defaults[section][key] = config.get(section, key) + # TODO: implement basic parsing/sanitization of options comming from + # config file. + return defaults -- cgit v1.2.3 From 4e06eb370b99f2d343e96f774a3ad9b8b77c9548 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 3 Oct 2016 19:27:42 -0300 Subject: [feature] check for user dbs couch schema versions --- server/src/leap/soledad/server/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index 97bcf888..2e1a453a 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -90,7 +90,7 @@ from leap.soledad.server.gzip_middleware import GzipMiddleware from leap.soledad.server.sync import SyncResource from leap.soledad.server.sync import MAX_REQUEST_SIZE from leap.soledad.server.sync import MAX_ENTRY_SIZE -from soledad.server.config import load_configuration +from leap.soledad.server.config import load_configuration from leap.soledad.common import SHARED_DB_NAME from leap.soledad.common.backend import SoledadBackend -- cgit v1.2.3 From 09a62dd1d6b076fcc7ac001d0b998ebb119feaad Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 5 Oct 2016 19:52:58 -0300 Subject: [tests] make check_schema_versions default to False CouchServerState is spread across test codebase and this option is intended to be used only on server startup. This commit makes it default to False and explicitly set it to True on where it's necessary. --- server/src/leap/soledad/server/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index 2e1a453a..e4fa4aa7 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -267,7 +267,8 @@ def _load_config(): def _get_couch_state(): conf = _load_config() - state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd']) + state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd'], + check_schema_versions=True) SoledadBackend.BATCH_SUPPORT = conf.get('batching', False) return state -- cgit v1.2.3 From a3836cd316c31a7256b2e110776e93c21cc772cc Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 14 Oct 2016 04:06:14 -0300 Subject: [tests] fix server import When importing server, couch_state will load itself against couch_db url configured on server. This fails when running on Docker as couchdb is in another node. --- server/src/leap/soledad/server/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'server') diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index e4fa4aa7..d154e3fe 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -272,12 +272,14 @@ def _get_couch_state(): SoledadBackend.BATCH_SUPPORT = conf.get('batching', False) return state +try: + _couch_state = _get_couch_state() + # a WSGI application that may be used by `twistd -web` + application = GzipMiddleware( + SoledadTokenAuthMiddleware(SoledadApp(_couch_state))) +except: + pass -_couch_state = _get_couch_state() - -# a WSGI application that may be used by `twistd -web` -application = GzipMiddleware( - SoledadTokenAuthMiddleware(SoledadApp(_couch_state))) # another WSGI application in which we bypass token auth middleware for ease of # mind while debugging in your local environment -- cgit v1.2.3 From 0fd7e9f018b02161a844c11332ffced56b256010 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 9 Nov 2016 11:20:12 -0200 Subject: [pkg] update leap requirements files --- server/pkg/requirements-leap.pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/pkg/requirements-leap.pip b/server/pkg/requirements-leap.pip index aaad340c..93b447e5 100644 --- a/server/pkg/requirements-leap.pip +++ b/server/pkg/requirements-leap.pip @@ -1 +1 @@ -leap.soledad.common>=0.6.5 +leap.soledad.common>=0.9.0 -- cgit v1.2.3