summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/config/initialize_leap.py1
-rw-r--r--service/pixelated/support/ext_shared_db.py15
2 files changed, 16 insertions, 0 deletions
diff --git a/service/pixelated/config/initialize_leap.py b/service/pixelated/config/initialize_leap.py
index a4610622..b693fde6 100644
--- a/service/pixelated/config/initialize_leap.py
+++ b/service/pixelated/config/initialize_leap.py
@@ -63,3 +63,4 @@ def init_monkeypatches():
import pixelated.support.ext_sync
import pixelated.support.ext_keymanager_fetch_key
import pixelated.support.ext_requests_urllib3
+ import pixelated.support.ext_shared_db
diff --git a/service/pixelated/support/ext_shared_db.py b/service/pixelated/support/ext_shared_db.py
new file mode 100644
index 00000000..83c09ddc
--- /dev/null
+++ b/service/pixelated/support/ext_shared_db.py
@@ -0,0 +1,15 @@
+from leap.soledad.client.auth import TokenBasedAuth
+import base64
+
+
+def patched_sign_request(self, method, url_query, params):
+ if 'token' in self._creds:
+ uuid, token = self._creds['token']
+ auth = '%s:%s' % (uuid, token)
+ return [('Authorization', 'Token %s' % base64.b64encode(auth))]
+ else:
+ raise errors.UnknownAuthMethod(
+ 'Wrong credentials: %s' % self._creds)
+
+
+TokenBasedAuth._sign_request = patched_sign_request