diff options
author | drebs <drebs@leap.se> | 2017-02-23 18:18:39 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-02-23 18:18:39 -0300 |
commit | 2422561268aa0214d8521ef5d2f456318391711d (patch) | |
tree | cf7f9562185d8787bc23d04e81d613c08d19d42e /client | |
parent | 459c5efd59e2ebaa21e5c461c275d866a43534e8 (diff) |
[refactor] use get_token in client secrets api
Diffstat (limited to 'client')
-rw-r--r-- | client/src/leap/soledad/client/_secrets/__init__.py | 4 | ||||
-rw-r--r-- | client/src/leap/soledad/client/_secrets/storage.py | 9 | ||||
-rw-r--r-- | client/src/leap/soledad/client/api.py | 3 |
3 files changed, 10 insertions, 6 deletions
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): """ |