diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-06-24 18:50:01 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-07-03 16:04:41 +0200 |
commit | e653aa169e9c1fbb00e1920cd461a7be6c9e11af (patch) | |
tree | cbb86c4b32e25847b342bec82137b8719270fe96 | |
parent | edaef12d080294a241fec895ae3255740433ecd8 (diff) |
[feat] use one single mail_auth token instead of imap/smtp tokens
The core was not addapted to the mail_auth token.
-rw-r--r-- | changes/next-changelog.rst | 2 | ||||
-rwxr-xr-x | src/leap/bitmask/cli/bitmask_cli.py | 13 | ||||
-rw-r--r-- | src/leap/bitmask/core/dispatcher.py | 15 | ||||
-rw-r--r-- | src/leap/bitmask/core/mail_services.py | 33 |
4 files changed, 19 insertions, 44 deletions
diff --git a/changes/next-changelog.rst b/changes/next-changelog.rst index 59f68d8d..389c3f33 100644 --- a/changes/next-changelog.rst +++ b/changes/next-changelog.rst @@ -10,6 +10,8 @@ I've added a new category `Misc` so we can track doc/style/packaging stuff. Features ~~~~~~~~ +- Use mail_auth token in the core instead of imap/smtp tokens. + - `#1234 <https://leap.se/code/issues/1234>`_: Description of the new feature corresponding with issue #1234. - New feature without related issue number. diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py index 5be6e9fc..49c5c3d3 100755 --- a/src/leap/bitmask/cli/bitmask_cli.py +++ b/src/leap/bitmask/cli/bitmask_cli.py @@ -107,10 +107,8 @@ GENERAL COMMANDS: help='displays status about the mail service') parser.add_argument('--enable', action='store_true') parser.add_argument('--disable', action='store_true') - parser.add_argument('--get-imap-token', action='store_true', - help='returns token for the IMAP service') - parser.add_argument('--get-smtp-token', action='store_true', - help='returns token for the SMTP service') + parser.add_argument('--get-token', action='store_true', + help='returns token for the mail service') parser.add_argument('--get-smtp-certificate', action='store_true', help='downloads a new smtp certificate') parser.add_argument('--check-smtp-certificate', action='store_true', @@ -276,11 +274,8 @@ def send_command(cli): elif subargs.disable: data += ['disable'] - elif subargs.get_imap_token: - data += ['get_imap_token'] - - elif subargs.get_smtp_token: - data += ['get_smtp_token'] + elif subargs.get_token: + data += ['get_token'] elif subargs.get_smtp_certificate: data += ['get_smtp_certificate'] diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index c07f5b95..ec3593e8 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -104,28 +104,23 @@ class MailCmd(SubCommand): label = 'mail' @register_method('dict') - def do_ENABLE(self, service, *parts): + def do_ENABLE(self, service, *parts, **kw): d = service.do_enable_service(self.label) return d @register_method('dict') - def do_DISABLE(self, service, *parts): + def do_DISABLE(self, service, *parts, **kw): d = service.do_disable_service(self.label) return d @register_method('dict') - def do_STATUS(self, mail, *parts): + def do_STATUS(self, mail, *parts, **kw): d = mail.do_status() return d @register_method('dict') - def do_GET_IMAP_TOKEN(self, mail, *parts): - d = mail.get_imap_token() - return d - - @register_method('dict') - def do_GET_SMTP_TOKEN(self, mail, *parts): - d = mail.get_smtp_token() + def do_GET_TOKEN(self, mail, *parts, **kw): + d = mail.get_token() return d @register_method('dict') diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 6a9155c6..b00db866 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -380,8 +380,7 @@ class StandardMailService(service.MultiService, HookableService): self._soledad_sessions = {} self._keymanager_sessions = {} self._sendmail_opts = {} - self._imap_tokens = {} - self._smtp_tokens = {} + self._service_tokens = {} self._active_user = None super(StandardMailService, self).__init__() self.initializeChildrenServices() @@ -414,20 +413,12 @@ class StandardMailService(service.MultiService, HookableService): incoming = self.getServiceNamed('incoming_mail') incoming.startInstance(userid) - def registerIMAPToken(token): - self._imap_tokens[userid] = token + def registerToken(token): + self._service_tokens[userid] = token self._active_user = userid - return token - def registerSMTPToken(token): - self._smtp_tokens[userid] = token - return token - - d = soledad.get_or_create_service_token('imap') - d.addCallback(registerIMAPToken) - d.addCallback( - lambda _: soledad.get_or_create_service_token('smtp')) - d.addCallback(registerSMTPToken) + d = soledad.get_or_create_service_token('mail_auth') + d.addCallback(registerToken) return d def stopInstance(self): @@ -450,21 +441,13 @@ class StandardMailService(service.MultiService, HookableService): def do_status(self): return 'mail: %s' % 'running' if self.running else 'disabled' - def get_imap_token(self): - active_user = self._active_user - if not active_user: - return defer.succeed('NO ACTIVE USER') - token = self._imap_tokens.get(active_user) - # TODO return just the tuple, no format. - return defer.succeed("IMAP TOKEN (%s): %s" % (active_user, token)) - - def get_smtp_token(self): + def get_token(self): active_user = self._active_user if not active_user: return defer.succeed('NO ACTIVE USER') - token = self._smtp_tokens.get(active_user) + token = self._service_tokens.get(active_user) # TODO return just the tuple, no format. - return defer.succeed("SMTP TOKEN (%s): %s" % (active_user, token)) + return defer.succeed("MAIL TOKEN (%s): %s" % (active_user, token)) def do_get_smtp_cert_path(self, userid): username, provider = userid.split('@') |