From 53715e689a2a0f46964a17582c23a949c324382b Mon Sep 17 00:00:00 2001 From: Andrew Colin Kissa Date: Thu, 7 Sep 2017 16:59:49 +0200 Subject: [PATCH] Pass the consul token as a header (#513) Headers are now the prefered way to pass the token to the consul API - https://www.consul.io/api/index.html#authentication --- patroni/dcs/consul.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patroni/dcs/consul.py b/patroni/dcs/consul.py index 840d5992..50ab3863 100644 --- a/patroni/dcs/consul.py +++ b/patroni/dcs/consul.py @@ -82,6 +82,8 @@ class HTTPClient(object): kwargs['timeout'] = (float(params['wait'][:-1]) if 'wait' in params else 300) + 1 else: kwargs['timeout'] = self._read_timeout + if isinstance(params, dict) and 'token' in params and params['token']: + kwargs['headers'] = {'X-Consul-Token': params.pop('token')} return callback(self.response(self.http.request(method.upper(), self.uri(path, params), **kwargs))) return wrapper