Projet

Général

Profil

0001-hobo-compute-api-secret-by-service-7192.patch

Voir les différences:

Subject: [PATCH] hobo: compute api secret by service (#7192)

 wcs/ctl/check_hobos.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
wcs/ctl/check_hobos.py
21 21
import sys
22 22
import tempfile
23 23
import urllib2
24
import urlparse
25
import hashlib
24 26

  
25 27
from qommon.ctl import Command, make_option
26 28
from qommon.storage import atomic_write
......
234 236
        config.set('hobo', 'timestamp', self.all_services.get('timestamp'))
235 237

  
236 238
        variables = {}
239
        api_secrets = {}
237 240
        for service in self.all_services.get('services', []):
238 241
            variables['%s_url' % service.get('slug')] = service.get('base_url')
242
            domain = urlparse.urlparse(service.get('base_url')).netloc.split(':')[0]
243
            api_secrets[domain] = hashlib.sha1(domain + service.get('secret_key')).hexdigest()
239 244
        if self.all_services.get('variables'):
240 245
            for key, value in self.all_services.get('variables').items():
241 246
                variables[key] = value
......
250 255
                value = unicode(value).encode('utf-8')
251 256
                config.set('variables', key, value)
252 257

  
258
        if not 'api-secrets' in config.sections():
259
            config.add_section('api-secrets')
260
        for key, value in api_secrets.items():
261
            config.set('api-secrets', key, value)
262

  
253 263
        if 'options' not in config.sections():
254 264
            config.add_section('options')
255 265
        for service in self.all_services.get('services', []):
256
-