From 5cff84723324b1fc01ea0962c0412bf7dc6027b4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 18 Jun 2018 20:22:09 +0300 Subject: Change: look up credentials using controller URL (fallback auth url) --- icktool | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'icktool') diff --git a/icktool b/icktool index 0866661..39def14 100755 --- a/icktool +++ b/icktool @@ -165,12 +165,13 @@ class Icktool(cliapp.Application): return api def _new_auth(self, api): - url = api.get_auth_url() - client_id, client_secret = self._get_client_creds(url) + c_url = api.get_controller_url() + auth_url = api.get_auth_url() + client_id, client_secret = self._get_client_creds(c_url, auth_url) ac = ick2.AuthClient() ac.set_http_api(api.get_http_api()) - ac.set_auth_url(url) + ac.set_auth_url(auth_url) ac.set_client_creds(client_id, client_secret) return ac @@ -185,11 +186,17 @@ class Icktool(cliapp.Application): sys.stderr.write('Error getting token: %s\n' % str(e)) sys.exit(1) - def _get_client_creds(self, url): + def _get_client_creds(self, controller_url, auth_url): cp = configparser.ConfigParser() cp.read(self.settings['secrets']) - client_id = cp.get(url, 'client_id') - client_secret = cp.get(url, 'client_secret') + + if cp.has_section(controller_url): + section = controller_url + else: + section = auth_url + + client_id = cp.get(section, 'client_id') + client_secret = cp.get(section, 'client_secret') return client_id, client_secret def _prettyson(self, obj): -- cgit v1.2.1