summaryrefslogtreecommitdiff
path: root/src/leap/soledad/shared_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/soledad/shared_db.py')
-rw-r--r--src/leap/soledad/shared_db.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/leap/soledad/shared_db.py b/src/leap/soledad/shared_db.py
index 419d8017..3929e828 100644
--- a/src/leap/soledad/shared_db.py
+++ b/src/leap/soledad/shared_db.py
@@ -29,10 +29,7 @@ except ImportError:
from u1db.remote import http_database, http_client
-from leap.soledad.auth import (
- set_token_credentials,
- _sign_request,
-)
+from leap.soledad.auth import TokenBasedAuth
SOLEDAD_CERT = None
@@ -78,7 +75,7 @@ class Unauthorized(Exception):
"""
-class SoledadSharedDatabase(http_database.HTTPDatabase):
+class SoledadSharedDatabase(http_database.HTTPDatabase, TokenBasedAuth):
"""
This is a shared recovery database that enables users to store their
encryption secrets in the server and retrieve them afterwards.
@@ -90,9 +87,32 @@ class SoledadSharedDatabase(http_database.HTTPDatabase):
# Token auth methods.
#
- set_token_credentials = set_token_credentials
+ def set_token_credentials(self, uuid, token):
+ """
+ Store given credentials so we can sign the request later.
+
+ @param uuid: The user's uuid.
+ @type uuid: str
+ @param token: The authentication token.
+ @type token: str
+ """
+ TokenBasedAuth.set_token_credentials(self, uuid, token)
- _sign_request = _sign_request
+ def _sign_request(self, method, url_query, params):
+ """
+ Return an authorization header to be included in the HTTP request.
+
+ @param method: The HTTP method.
+ @type method: str
+ @param url_query: The URL query string.
+ @type url_query: str
+ @param params: A list with encoded query parameters.
+ @type param: list
+
+ @return: The Authorization header.
+ @rtype: list of tuple
+ """
+ return TokenBasedAuth._sign_request(self, method, url_query, params)
#
# Modified HTTPDatabase methods.