diff options
author | drebs <drebs@leap.se> | 2017-02-23 18:06:07 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-02-23 18:06:07 -0300 |
commit | 1ab75f97d77f9883c4d83d43513d9d47dfb397d9 (patch) | |
tree | 65d8dd828c9f45a754960f32129302510058c1ce /client | |
parent | 193573cf8d44a3b6a7d8ae0e43988cffb38a428a (diff) |
[refactor] remove creds from client api
Diffstat (limited to 'client')
-rw-r--r-- | client/src/leap/soledad/client/api.py | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py index 54cbcd9d..6a508d05 100644 --- a/client/src/leap/soledad/client/api.py +++ b/client/src/leap/soledad/client/api.py @@ -187,7 +187,7 @@ class Soledad(object): global SOLEDAD_CERT SOLEDAD_CERT = cert_file - self._set_token(auth_token) + self.set_token(auth_token) self._init_config_with_defaults() self._init_working_dirs() @@ -249,9 +249,10 @@ 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, - self._creds, self.userid, shared_db=shared_db) + creds, self.userid, shared_db=shared_db) def _init_u1db_sqlcipher_backend(self): """ @@ -675,9 +676,8 @@ class Soledad(object): sync_url = urlparse.urljoin(self._server_url, 'user-%s' % self.uuid) if not self._dbsyncer: return - d = self._dbsyncer.sync( - sync_url, - creds=self._creds) + creds = {'token': {'uuid': self.uuid, 'token': self.token}} + d = self._dbsyncer.sync(sync_url, creds=creds) def _sync_callback(local_gen): self._last_received_docs = docs = self._dbsyncer.received_docs @@ -734,37 +734,13 @@ class Soledad(object): """ return self.sync_lock.locked - def _set_token(self, token): - """ - Set the authentication token for remote database access. - - Internally, this builds the credentials dictionary with the following - format: + def set_token(self, token): + self._token = token - { - 'token': { - 'uuid': '<uuid>' - 'token': '<token>' - } - } - - :param token: The authentication token. - :type token: str - """ - self._creds = { - 'token': { - 'uuid': self.uuid, - 'token': token, - } - } - - def _get_token(self): - """ - Return current token from credentials dictionary. - """ - return self._creds['token']['token'] + def get_token(self): + return self._token - token = property(_get_token, _set_token, doc='The authentication Token.') + token = property(get_token, set_token, doc='The authentication Token.') # # ISecretsStorage |