summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-12-16 15:33:25 -0400
committerKali Kaneko <kali@leap.se>2015-12-18 11:20:21 -0400
commit7b80dd1fca9828331f3327c418913539a3a303c0 (patch)
treecc4e73f25cecb2d286fcbb12b664f2eb42f12e76 /src
parent98384361a7c49ad4e0ff0127fd923a8b72cc910a (diff)
[feat] adapt to use cred-based authentication for smtp
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/backend/components.py14
-rw-r--r--src/leap/bitmask/gui/mainwindow.py16
-rw-r--r--src/leap/bitmask/services/mail/smtpbootstrapper.py33
3 files changed, 38 insertions, 25 deletions
diff --git a/src/leap/bitmask/backend/components.py b/src/leap/bitmask/backend/components.py
index a07d3bad..e93ca19f 100644
--- a/src/leap/bitmask/backend/components.py
+++ b/src/leap/bitmask/backend/components.py
@@ -797,16 +797,19 @@ class Soledad(object):
def _set_service_tokens_cb(self, result):
- def register_imap_token(imap_token):
- self._service_tokens['imap'] = imap_token
+ def register_service_token(token, service):
+ self._service_tokens[service] = token
if self._signaler is not None:
self._signaler.signal(
self._signaler.soledad_got_service_token,
- ('imap', imap_token))
+ (service, token))
sol = self._soledad_bootstrapper.soledad
d = sol.get_or_create_service_token('imap')
- d.addCallback(register_imap_token)
+ d.addCallback(register_service_token, 'imap')
+ d.addCallback(
+ lambda _: sol.get_or_create_service_token('smtp'))
+ d.addCallback(register_service_token, 'smtp')
d.addCallback(lambda _: result)
return d
@@ -1035,7 +1038,8 @@ class Mail(object):
"""
return threads.deferToThread(
self._smtp_bootstrapper.start_smtp_service,
- self._keymanager_proxy, full_user_id, download_if_needed)
+ self._soledad_proxy, self._keymanager_proxy, full_user_id,
+ download_if_needed)
def start_imap_service(self, full_user_id, offline=False):
"""
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 189a6295..759b454f 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -1075,11 +1075,14 @@ class MainWindow(QtGui.QMainWindow, SignalTracker):
manual_smtp = self.tr("SMTP: localhost, port {0}".format(smtp_port))
manual_username = self.tr("Username: your full email address")
- # TODO this should be a widget that allows to be copied to the
- # clipboard.
- imap_token = (self._service_tokens.get('imap', None)
- or "??? (log in to unlock)")
- manual_password = self.tr("Password: ") + "%s" % (imap_token, )
+ # FIXME on i3, this doens't allow to mouse-select.
+ # Switch to a dialog in which we can set the QLabel
+ imap_token = (self._service_tokens.get('imap', None) or
+ "??? (log in to unlock)")
+ smtp_token = (self._service_tokens.get('smtp', None) or
+ "??? (log in to unlock)")
+ imap_password = self.tr("IMAP Password:") + " %s" % (imap_token,)
+ smtp_password = self.tr("SMTP Password:") + " %s" % (smtp_token,)
msg = help_url + self.tr(
"<p><strong>{0}</strong></p>"
@@ -1090,9 +1093,10 @@ class MainWindow(QtGui.QMainWindow, SignalTracker):
"<li>&nbsp;{4}</li>"
"<li>&nbsp;{5}</li>"
"<li>&nbsp;{6}</li>"
+ "<li>&nbsp;{7}</li>"
"</ul></p>").format(email_quick_reference, thunderbird_text,
manual_text, manual_imap, manual_smtp,
- manual_username, manual_password)
+ manual_username, imap_password, smtp_password)
QtGui.QMessageBox.about(self, self.tr("Bitmask Help"), msg)
def _needs_update(self):
diff --git a/src/leap/bitmask/services/mail/smtpbootstrapper.py b/src/leap/bitmask/services/mail/smtpbootstrapper.py
index a577509e..dadf59dd 100644
--- a/src/leap/bitmask/services/mail/smtpbootstrapper.py
+++ b/src/leap/bitmask/services/mail/smtpbootstrapper.py
@@ -19,6 +19,7 @@ SMTP bootstrapping
"""
import os
import warnings
+from collections import namedtuple
from requests.exceptions import HTTPError
@@ -127,9 +128,6 @@ class SMTPBootstrapper(AbstractBootstrapper):
Start the smtp service using the downloaded configurations.
"""
# TODO Make the encrypted_only configurable
- # TODO pick local smtp port in a better way
- # TODO remove hard-coded port and let leap.mail set
- # the specific default.
# TODO handle more than one host and define how to choose
hosts = self._smtp_config.get_hosts()
hostname = hosts.keys()[0]
@@ -138,19 +136,25 @@ class SMTPBootstrapper(AbstractBootstrapper):
client_cert_path = self._smtp_config.get_client_cert_path(
self._userid, self._provider_config, about_to_download=True)
- from leap.mail.smtp import setup_smtp_gateway
+ # XXX this should be defined in leap.mail.smtp, it's in bitmask.core
+ # right now.
+ SendmailOpts = namedtuple(
+ 'SendmailOpts', ['cert', 'key', 'hostname', 'port'])
- self._smtp_service, self._smtp_port = setup_smtp_gateway(
- port=2013,
- userid=self._userid,
- keymanager=self._keymanager,
- smtp_host=host,
- smtp_port=port,
- smtp_cert=client_cert_path,
- smtp_key=client_cert_path,
- encrypted_only=False)
+ userid = self._userid
+ soledad_sessions = {userid: self._soledad}
+ keymanager_sessions = {userid: self._keymanager}
- def start_smtp_service(self, keymanager, userid, download_if_needed=False):
+ key = cert = client_cert_path
+ opts = SendmailOpts(cert, key, host, port)
+ sendmail_opts = {userid: opts}
+
+ from leap.mail.smtp import run_service
+ self._smtp_service, self._smtp_port = run_service(
+ soledad_sessions, keymanager_sessions, sendmail_opts)
+
+ def start_smtp_service(self, soledad, keymanager, userid,
+ download_if_needed=False):
"""
Starts the SMTP service.
@@ -170,6 +174,7 @@ class SMTPBootstrapper(AbstractBootstrapper):
raise MalformedUserId()
self._provider_config = ProviderConfig.get_provider_config(domain)
+ self._soledad = soledad
self._keymanager = keymanager
self._smtp_config = SMTPConfig()
self._userid = str(userid)