summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-08-23 05:25:54 -0300
committerdrebs <drebs@riseup.net>2017-09-05 11:08:47 -0300
commit90685484c829d98db74dfd8e1cf01ed418f3c423 (patch)
tree5cb70058175be25f56480b33364df3cb137b4692
parent54f28b30c81da5f699cc90846f182377d9efb11a (diff)
[refactor] add localhost endpoint to server tac
-- Related: #8867
-rw-r--r--pkg/server.tac7
-rw-r--r--src/leap/soledad/server/_resource.py5
-rw-r--r--src/leap/soledad/server/auth.py3
-rw-r--r--src/leap/soledad/server/entrypoint.py7
4 files changed, 19 insertions, 3 deletions
diff --git a/pkg/server.tac b/pkg/server.tac
index ef2cea50..1bc3dc69 100644
--- a/pkg/server.tac
+++ b/pkg/server.tac
@@ -7,6 +7,13 @@ from leap.soledad.server import entrypoint
application = service.Application('soledad-server')
+# local entrypoint
+local_description = 'tcp:2323:interface=127.0.0.1'
+local_site = server.Site(entrypoint.LocalServicesEntrypoint())
+
+local_server = strports.service(local_description, local_site)
+local_server.setServiceParent(application)
+
# public entrypoint
port = os.getenv('HTTPS_PORT', None)
if port:
diff --git a/src/leap/soledad/server/_resource.py b/src/leap/soledad/server/_resource.py
index e4c51ded..c097fad8 100644
--- a/src/leap/soledad/server/_resource.py
+++ b/src/leap/soledad/server/_resource.py
@@ -55,8 +55,9 @@ class LocalResource(Resource):
Used for localhost endpoints, like IncomingBox delivery.
"""
- def __init__(conf):
- pass
+ def __init__(self):
+ Resource.__init__(self)
+ self.putChild('incoming', IncomingResource())
class SoledadResource(Resource):
diff --git a/src/leap/soledad/server/auth.py b/src/leap/soledad/server/auth.py
index 934517b5..4dbe9a6d 100644
--- a/src/leap/soledad/server/auth.py
+++ b/src/leap/soledad/server/auth.py
@@ -86,7 +86,7 @@ class LocalServicesRealm(object):
conf = get_config()
self.anon_resource = SoledadAnonResource(
enable_blobs=conf['blobs'])
- self.auth_resource = LocalResource(conf)
+ self.auth_resource = LocalResource()
def requestAvatar(self, avatarId, mind, *interfaces):
@@ -105,6 +105,7 @@ class LocalServicesRealm(object):
@implementer(ICredentialsChecker)
class FileTokenChecker(object):
+ credentialInterfaces = [IUsernamePassword, IAnonymous]
def __init__(self, conf=None):
conf = conf or get_config()
diff --git a/src/leap/soledad/server/entrypoint.py b/src/leap/soledad/server/entrypoint.py
index 9b9a5e66..7115007b 100644
--- a/src/leap/soledad/server/entrypoint.py
+++ b/src/leap/soledad/server/entrypoint.py
@@ -44,7 +44,14 @@ class SoledadEntrypoint(SoledadSession):
SoledadSession.__init__(self, portal)
+class LocalServicesEntrypoint(SoledadSession):
+
+ def __init__(self):
+ portal = portalFactory(public=False)
+ SoledadSession.__init__(self, portal)
+
# see the comments in application.py recarding why couch state has to be
# initialized when the reactor is running
+
reactor.callWhenRunning(init_couch_state, conf)