summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-09-15 23:00:21 +0200
committerKali Kaneko <kali@leap.se>2017-09-18 15:37:52 +0200
commit73e1944c876421cccd41206f83d0c5db83722607 (patch)
treec5b63f5f6e98d3b521823b5b93ec59dccb2cfd4e /src
parent66da85d6c8fcba3f7b0b401cd9b8c6183a061a47 (diff)
[bug] we need to use 'GET' method to fetch provider configs
The workaround is no needed anymore, if we do 'GET' instead of 'POST' to fetch all the provider configuration jsons it works smoothly. - Resolves: #9056
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/bonafide/config.py55
-rw-r--r--src/leap/bitmask/bonafide/session.py4
2 files changed, 3 insertions, 56 deletions
diff --git a/src/leap/bitmask/bonafide/config.py b/src/leap/bitmask/bonafide/config.py
index d892f47..6857a3f 100644
--- a/src/leap/bitmask/bonafide/config.py
+++ b/src/leap/bitmask/bonafide/config.py
@@ -407,57 +407,6 @@ class Provider(object):
self._load_provider_configs()
return True
- def workaround_for_failed_config_fetch(failure):
- # FIXME --- configs.json raises 500, see #7914.
- # This is a workaround until that's fixed.
- self.log.debug(
- 'COULD NOT VERIFY CONFIGS.JSON, WORKAROUND: DIRECT DOWNLOAD')
-
- deferreds = []
- services = self._provider_config.services
-
- if 'mx' in services:
- soledad_uri = '/1/config/soledad-service.json'
- smtp_uri = '/1/config/smtp-service.json'
- base = self._disco.netloc
-
- fetch = self._fetch_provider_configs_unauthenticated
- get_path = self._get_service_config_path
-
- d1 = fetch(
- 'https://' + str(base + soledad_uri), get_path('soledad'))
- d2 = fetch(
- 'https://' + str(base + smtp_uri), get_path('smtp'))
- deferreds += [d1, d2]
-
- if 'openvpn' in services:
- openvpn_uri = '/1/config/eip-service.json'
- base = self._disco.netloc
-
- fetch = self._fetch_provider_configs_unauthenticated
- get_path = self._get_service_config_path
-
- d3 = fetch(
- 'https://' + str(base + openvpn_uri), get_path('eip'))
- deferreds += [d3]
-
- d = defer.gatherResults(deferreds)
- d.addCallback(lambda _: finish_stuck_after_workaround())
- return d
-
- def check_if_invalid_config_fetch(ignored):
- # For some old versions of the webapp, it returns a 200 but
- # downloads a non-valid file. See #9004
- try:
- json.loads(open(self.get_configs_path()).read())
- except ValueError:
- workaround_for_failed_config_fetch(None)
-
- def finish_stuck_after_workaround():
- stuck = self.stuck_bootstrap.get(self._domain, None)
- if stuck:
- stuck.callback('continue!')
-
def complete_bootstrapping(ignored):
stuck = self.stuck_bootstrap.get(self._domain, None)
if stuck:
@@ -468,11 +417,9 @@ class Provider(object):
if not self.has_fetched_services_config():
self._load_provider_json()
uri, met, path = self._get_configs_download_params()
- d = session.fetch_provider_configs(uri, path)
+ d = session.fetch_provider_configs(uri, path, met)
d.addCallback(verify_provider_configs)
d.addCallback(complete_bootstrapping)
- d.addCallback(check_if_invalid_config_fetch)
- d.addErrback(workaround_for_failed_config_fetch)
return d
else:
d = defer.succeed('already downloaded')
diff --git a/src/leap/bitmask/bonafide/session.py b/src/leap/bitmask/bonafide/session.py
index a05e209..711e9ee 100644
--- a/src/leap/bitmask/bonafide/session.py
+++ b/src/leap/bitmask/bonafide/session.py
@@ -200,8 +200,8 @@ class Session(object):
# Authentication-protected configuration
@defer.inlineCallbacks
- def fetch_provider_configs(self, uri, path):
- config = yield self._request(self._agent, uri)
+ def fetch_provider_configs(self, uri, path, method='GET'):
+ config = yield self._request(self._agent, uri, method=method)
with open(path, 'w') as cf:
cf.write(config)
defer.returnValue('ok')