summaryrefslogtreecommitdiff
path: root/src/leap/soledad/server.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-05-23 12:03:50 -0300
committerdrebs <drebs@leap.se>2013-05-23 12:46:33 -0300
commit177bfa18ac33f281d0a4f12555f0f3b7c84efc3d (patch)
treee51df13f62c98195d8472264316ea40ff97c1312 /src/leap/soledad/server.py
parent3214e542c7e5ebaadd704c17f2a34858b7b8e92e (diff)
Ensure shared db is created by server.
* Also remove unneeded need_auth() method (because all requests need auth). * This closes #2491.
Diffstat (limited to 'src/leap/soledad/server.py')
-rw-r--r--src/leap/soledad/server.py27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/leap/soledad/server.py b/src/leap/soledad/server.py
index 7aa253a3..331f64aa 100644
--- a/src/leap/soledad/server.py
+++ b/src/leap/soledad/server.py
@@ -171,21 +171,6 @@ class SoledadAuthMiddleware(object):
return False
return True
- def need_auth(self, environ):
- """
- Check if action can be performed on database without authentication.
-
- For now, just allow access to /shared/*.
-
- @param environ: Dictionary containing CGI variables.
- @type environ: dict
-
- @return: Whether the requests needs authentication.
- @rtype: bool
- """
- # TODO: design unauth verification.
- return not environ.get(self.PATH_INFO_KEY).startswith('/shared/')
-
#-----------------------------------------------------------------------------
# Soledad WSGI application
@@ -196,6 +181,11 @@ class SoledadApp(http_app.HTTPApp):
Soledad WSGI application
"""
+ SHARED_DB_NAME = 'shared'
+ """
+ The name of the shared database that holds user's encrypted secrets.
+ """
+
def __call__(self, environ, start_response):
"""
Handle a WSGI call to the Soledad application.
@@ -209,6 +199,8 @@ class SoledadApp(http_app.HTTPApp):
@return: HTTP application results.
@rtype: list
"""
+ # ensure the shared database exists
+ self.state.ensure_database(self.SHARED_DB_NAME)
return http_app.HTTPApp.__call__(self, environ, start_response)
@@ -244,11 +236,10 @@ def load_configuration(file_path):
# Run as Twisted WSGI Resource
#-----------------------------------------------------------------------------
-# TODO: create command-line option for choosing config file.
conf = load_configuration('/etc/leap/soledad-server.conf')
state = CouchServerState(conf['couch_url'])
-application = SoledadAuthMiddleware(
- SoledadApp(state))
+# WSGI application that may be used by `twistd -web`
+application = SoledadAuthMiddleware(SoledadApp(state))
resource = WSGIResource(reactor, reactor.getThreadPool(), application)