From da20b336297394482ebe3433067c42d5dd4eeb85 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Mon, 11 May 2015 17:27:17 +0200 Subject: [PATCH] hobo: compute api secret by service (#7192) --- wcs/ctl/check_hobos.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py index 1d6a4da..b7739c7 100644 --- a/wcs/ctl/check_hobos.py +++ b/wcs/ctl/check_hobos.py @@ -21,6 +21,8 @@ import subprocess import sys import tempfile import urllib2 +import urlparse +import hashlib from qommon.ctl import Command, make_option from qommon.storage import atomic_write @@ -176,8 +178,11 @@ class CmdCheckHobos(Command): config.set('hobo', 'timestamp', self.all_services.get('timestamp')) variables = {} + api_secrets = {} for service in self.all_services.get('services', []): variables['%s_url' % service.get('slug')] = service.get('base_url') + domain = urlparse.urlparse(service.get('base_url')).netloc.split(':')[0] + api_secrets[domain] = hashlib.sha1(domain + service.get('secret_key')).hexdigest() if self.all_services.get('variables'): for key, value in self.all_services.get('variables').items(): variables[key] = value @@ -192,6 +197,12 @@ class CmdCheckHobos(Command): value = unicode(value).encode('utf-8') config.set('variables', key, value) + if api_secrets: + if not 'api-secrets' in config.sections(): + config.add_section('api-secrets') + for key, value in api_secrets.items(): + config.set('api-secrets', key, value) + if 'options' not in config.sections(): config.add_section('options') for service in self.all_services.get('services', []): -- 2.1.4