From 2422561268aa0214d8521ef5d2f456318391711d Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 23 Feb 2017 18:18:39 -0300 Subject: [refactor] use get_token in client secrets api --- client/src/leap/soledad/client/_secrets/__init__.py | 4 ++-- client/src/leap/soledad/client/_secrets/storage.py | 9 +++++++-- client/src/leap/soledad/client/api.py | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'client/src/leap') diff --git a/client/src/leap/soledad/client/_secrets/__init__.py b/client/src/leap/soledad/client/_secrets/__init__.py index 26294364..69c9141f 100644 --- a/client/src/leap/soledad/client/_secrets/__init__.py +++ b/client/src/leap/soledad/client/_secrets/__init__.py @@ -43,7 +43,7 @@ class Secrets(EmitMixin): 'local_secret': 448, # local_secret to derive a local_key for storage } - def __init__(self, uuid, passphrase, url, local_path, creds, userid, + def __init__(self, uuid, passphrase, url, local_path, get_token, userid, shared_db=None): self._uuid = uuid self._passphrase = passphrase @@ -51,7 +51,7 @@ class Secrets(EmitMixin): self._secrets = {} self.crypto = SecretsCrypto(self.get_passphrase) self.storage = SecretsStorage( - uuid, self.get_passphrase, url, local_path, creds, userid, + uuid, self.get_passphrase, url, local_path, get_token, userid, shared_db=shared_db) self._bootstrap() diff --git a/client/src/leap/soledad/client/_secrets/storage.py b/client/src/leap/soledad/client/_secrets/storage.py index 730926ee..5fde8988 100644 --- a/client/src/leap/soledad/client/_secrets/storage.py +++ b/client/src/leap/soledad/client/_secrets/storage.py @@ -33,16 +33,21 @@ logger = getLogger(__name__) class SecretsStorage(EmitMixin): - def __init__(self, uuid, get_pass, url, local_path, creds, userid, + def __init__(self, uuid, get_pass, url, local_path, get_token, userid, shared_db=None): self._uuid = uuid self._get_pass = get_pass self._local_path = local_path + self._get_token = get_token self._userid = userid - self._shared_db = shared_db or self._init_shared_db(url, creds) + self._shared_db = shared_db or self._init_shared_db(url, self._creds) self.__remote_doc = None + @property + def _creds(self): + return {'token': {'uuid': self._uuid, 'token': self._get_token()}} + # # local storage # diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py index 6a508d05..e84ba848 100644 --- a/client/src/leap/soledad/client/api.py +++ b/client/src/leap/soledad/client/api.py @@ -249,10 +249,9 @@ class Soledad(object): """ Initialize Soledad secrets. """ - creds = {'token': {'uuid': self.uuid, 'token': self.token}} self._secrets = Secrets( self._uuid, self._passphrase, self._server_url, self._secrets_path, - creds, self.userid, shared_db=shared_db) + self.get_token, self.userid, shared_db=shared_db) def _init_u1db_sqlcipher_backend(self): """ -- cgit v1.2.3