From 3493e2fbe21bd8058f4364c0b122e80eb0504bcb 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py index aa38e98..19af32c 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 @@ -234,8 +236,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 @@ -250,6 +255,11 @@ class CmdCheckHobos(Command): value = unicode(value).encode('utf-8') config.set('variables', key, value) + 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