Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Théo Giovanna
bitmask_client
Commits
e653aa16
Unverified
Commit
e653aa16
authored
Jun 24, 2016
by
meskio
⛺
Browse files
[feat] use one single mail_auth token instead of imap/smtp tokens
The core was not addapted to the mail_auth token.
parent
edaef12d
Changes
4
Hide whitespace changes
Inline
Side-by-side
changes/next-changelog.rst
View file @
e653aa16
...
...
@@ -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.
...
...
src/leap/bitmask/cli/bitmask_cli.py
View file @
e653aa16
...
...
@@ -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'
]
...
...
src/leap/bitmask/core/dispatcher.py
View file @
e653aa16
...
...
@@ -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'
)
...
...
src/leap/bitmask/core/mail_services.py
View file @
e653aa16
...
...
@@ -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
register
IMAP
Token
(
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
.
_s
mtp
_tokens
.
get
(
active_user
)
token
=
self
.
_s
ervice
_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
(
'@'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment