diff options
author | Bruno Wagner <bwagner@riseup.net> | 2016-09-01 17:43:33 -0300 |
---|---|---|
committer | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-09-12 14:39:33 -0300 |
commit | 1114cfcfba7b67b9d3e6238ce9dc2ab578060f93 (patch) | |
tree | 0657df05700b9a215a25e2324afd66530a1c3aa5 /service | |
parent | e7f9c3c7220618438830cd36361db5089351cf81 (diff) |
Implements bonafide to replace leap.auth
This still uses the SRPSession object to hold the credentials
so we don't have to adapt the rest of the user agent code
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/config/leap.py | 17 | ||||
-rw-r--r-- | service/requirements.txt | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py index 42eb495d..22c1e57a 100644 --- a/service/pixelated/config/leap.py +++ b/service/pixelated/config/leap.py @@ -1,10 +1,13 @@ from __future__ import absolute_import import logging +from collections import namedtuple from twisted.internet import defer, threads from leap.common.events import (server as events_server) from leap.soledad.common.errors import InvalidAuthTokenError -from leap.auth import SRPAuth +from leap.auth import SRPSession +from leap.bonafide.session import Session +from leap.bonafide.provider import Api from pixelated.config import credentials from pixelated.config import leap_config from pixelated.bitmask_libraries.certs import LeapCertificate @@ -14,6 +17,9 @@ from pixelated.config.sessions import LeapSessionFactory log = logging.getLogger(__name__) +Credentials = namedtuple('Credentials', 'username, password') + + def initialize_leap_provider(provider_hostname, provider_cert, provider_fingerprint, leap_home): LeapCertificate.set_cert_and_fingerprint(provider_cert, provider_fingerprint) @@ -75,10 +81,13 @@ def initialize_leap_single_user(leap_provider_cert, defer.returnValue(leap_session) +@defer.inlineCallbacks def authenticate(provider, user, password): - srp_auth = SRPAuth(provider.api_uri, provider.local_ca_crt) - d = threads.deferToThread(srp_auth.authenticate, user, password) - return d + srp_provider = Api(provider.api_uri) + credentials = Credentials(user, password) + srp_auth = Session(credentials, srp_provider, provider.local_ca_crt) + yield srp_auth.authenticate() + defer.returnValue(SRPSession(user, srp_auth.token, srp_auth.uuid, 'session_id', {'is_admin': False})) def init_monkeypatches(): diff --git a/service/requirements.txt b/service/requirements.txt index b4968f7d..bbc5044e 100644 --- a/service/requirements.txt +++ b/service/requirements.txt @@ -9,6 +9,7 @@ whoosh==2.5.7 Twisted==16.1.1 -e 'git+https://github.com/pixelated/leap_pycommon.git@develop#egg=leap.common' -e 'git+https://github.com/pixelated/leap_auth.git#egg=leap.auth' +-e 'git+https://github.com/leapcode/bonafide.git@master#egg=leap.bonafide' -e 'git+https://github.com/pixelated/soledad.git@develop#egg=leap.soledad.common&subdirectory=common/' -e 'git+https://github.com/pixelated/soledad.git@develop#egg=leap.soledad.client&subdirectory=client/' -e 'git+https://github.com/pixelated/soledad.git@develop#egg=leap.soledad.server&subdirectory=server/' |