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 | 11 +++++++++++
 1 file changed, 11 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
......
176 178
        config.set('hobo', 'timestamp', self.all_services.get('timestamp'))
177 179

  
178 180
        variables = {}
181
        api_secrets = {}
179 182
        for service in self.all_services.get('services', []):
180 183
            variables['%s_url' % service.get('slug')] = service.get('base_url')
184
            domain = urlparse.urlparse(service.get('base_url')).netloc.split(':')[0]
185
            api_secrets[domain] = hashlib.sha1(domain + service.get('secret_key')).hexdigest()
181 186
        if self.all_services.get('variables'):
182 187
            for key, value in self.all_services.get('variables').items():
183 188
                variables[key] = value
......
192 197
                value = unicode(value).encode('utf-8')
193 198
                config.set('variables', key, value)
194 199

  
200
        if api_secrets:
201
            if not 'api-secrets' in config.sections():
202
                config.add_section('api-secrets')
203
            for key, value in api_secrets.items():
204
                config.set('api-secrets', key, value)
205

  
195 206
        if 'options' not in config.sections():
196 207
            config.add_section('options')
197 208
        for service in self.all_services.get('services', []):
198
-