summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/feature_5120_update-keymanager-to-webapp-v21
-rw-r--r--src/leap/bitmask/services/soledad/soledadbootstrapper.py23
2 files changed, 16 insertions, 8 deletions
diff --git a/changes/feature_5120_update-keymanager-to-webapp-v2 b/changes/feature_5120_update-keymanager-to-webapp-v2
new file mode 100644
index 00000000..71aa3d5e
--- /dev/null
+++ b/changes/feature_5120_update-keymanager-to-webapp-v2
@@ -0,0 +1 @@
+- Update key manager auth to interact with webapp v2 (#5120).
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index b61d0d43..7aa86a02 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -20,15 +20,16 @@ Soledad bootstrapping
import logging
import os
import socket
-import sqlite3
import sys
from ssl import SSLError
+from sqlite3 import ProgrammingError as sqlite_ProgrammingError
from PySide import QtCore
from u1db import errors as u1db_errors
from twisted.internet import threads
from zope.proxy import sameProxiedObjects
+from pysqlcipher.dbapi2 import ProgrammingError as sqlcipher_ProgrammingError
from leap.bitmask.config import flags
from leap.bitmask.config.providerconfig import ProviderConfig
@@ -287,13 +288,13 @@ class SoledadBootstrapper(AbstractBootstrapper):
"Null soledad, error while initializing")
if flags.OFFLINE is True:
- self._init_keymanager(self._address)
+ self._init_keymanager(self._address, token)
self.local_only_ready.emit({self.PASSED_KEY: True})
else:
try:
address = make_address(
self._user, self._provider_config.get_domain())
- self._init_keymanager(address)
+ self._init_keymanager(address, token)
self._keymanager.get_key(
address, openpgp.OpenPGPKey,
private=True, fetch_remote=False)
@@ -440,7 +441,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
except u1db_errors.InvalidGeneration as exc:
logger.error("%r" % (exc,))
raise SoledadSyncError("u1db: InvalidGeneration")
- except sqlite3.ProgrammingError as e:
+ except (sqlite_ProgrammingError, sqlcipher_ProgrammingError) as e:
logger.exception("%r" % (e,))
raise
except Exception as exc:
@@ -502,12 +503,14 @@ class SoledadBootstrapper(AbstractBootstrapper):
leap_check(gpgbin is not None, "Could not find gpg binary")
return gpgbin
- def _init_keymanager(self, address):
+ def _init_keymanager(self, address, token):
"""
Initialize the keymanager.
:param address: the address to initialize the keymanager with.
:type address: str
+ :param token: the auth token for accessing webapp.
+ :type token: str
"""
srp_auth = self.srpauth
logger.debug('initializing keymanager...')
@@ -515,7 +518,6 @@ class SoledadBootstrapper(AbstractBootstrapper):
if flags.OFFLINE is True:
args = (address, "https://localhost", self._soledad)
kwargs = {
- "session_id": "",
"ca_cert_path": "",
"api_uri": "",
"api_version": "",
@@ -530,7 +532,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
self._soledad
)
kwargs = {
- "session_id": srp_auth.get_session_id(),
+ "token": token,
"ca_cert_path": self._provider_config.get_ca_cert_path(),
"api_uri": self._provider_config.get_api_uri(),
"api_version": self._provider_config.get_api_version(),
@@ -539,15 +541,20 @@ class SoledadBootstrapper(AbstractBootstrapper):
}
try:
self._keymanager = KeyManager(*args, **kwargs)
+ except KeyNotFound:
+ logger.debug('key for %s not found.' % address)
except Exception as exc:
logger.exception(exc)
raise
if flags.OFFLINE is False:
# make sure key is in server
- logger.debug('sending key to server...')
+ logger.debug('Trying to send key to server...')
try:
self._keymanager.send_key(openpgp.OpenPGPKey)
+ except KeyNotFound:
+ logger.debug('No key found for %s, will generate soon.'
+ % address)
except Exception as exc:
logger.error("Error sending key to server.")
logger.exception(exc)