diff options
author | drebs <drebs@leap.se> | 2013-04-25 23:15:06 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-04-25 23:15:06 -0300 |
commit | cc9537b9c73c6f502dc4576df0aee4409e887d47 (patch) | |
tree | 368b8e4d690d2cdf18f87f2d0e78f4afdb3b8153 /src/leap/soledad/backends | |
parent | 2ef514b02fa37a0a2ebac0bb9668543e29033a7f (diff) |
Add token auth infrastructure.
Diffstat (limited to 'src/leap/soledad/backends')
-rw-r--r-- | src/leap/soledad/backends/leap_backend.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/leap/soledad/backends/leap_backend.py b/src/leap/soledad/backends/leap_backend.py index 05c27bc1..51c471eb 100644 --- a/src/leap/soledad/backends/leap_backend.py +++ b/src/leap/soledad/backends/leap_backend.py @@ -394,3 +394,15 @@ class LeapSyncTarget(HTTPSyncTarget): res = self._parse_sync_stream(data, return_doc_cb, ensure_callback) data = None return res['new_generation'], res['new_transaction_id'] + + def set_token_credentials(self, address, token): + self._creds = {'token': (address, token)} + + def _sign_request(self, method, url_query, params): + if 'token' in self._creds: + address, token = self._creds['token'] + auth = '%s:%s' % (address, token) + return [('Authorization', 'Token %s' % auth.encode('base64'))] + else: + return HTTPSyncTarget._sign_request( + self, method, url_query, params) |