summaryrefslogtreecommitdiff
path: root/openstackclient/common/clientmanager.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-10-17 23:27:28 +0000
committerGerrit Code Review <review@openstack.org>2014-10-17 23:27:28 +0000
commit68130fa92182760882def8d3a3a97fcde5d355a1 (patch)
treee46a739aaa934883b9c749fc7e40fdfa22b163c7 /openstackclient/common/clientmanager.py
parentefc572efc1ac4ad4c595c772bf7daa1cd94e25eb (diff)
parentc3c6edbe8a083aef0fb6aea3cb461ff8e715fc59 (diff)
downloadpython-openstackclient-68130fa92182760882def8d3a3a97fcde5d355a1.tar.gz
Merge "Add plugin to support token-endpoint auth"
Diffstat (limited to 'openstackclient/common/clientmanager.py')
-rw-r--r--openstackclient/common/clientmanager.py41
1 files changed, 20 insertions, 21 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index dc0791df..928ab6ee 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -56,9 +56,10 @@ class ClientManager(object):
return self._auth_params[name[1:]]
def __init__(self, auth_options, api_version=None, verify=True):
-
+ # If no plugin is named by the user, select one based on
+ # the supplied options
if not auth_options.os_auth_plugin:
- auth._guess_authentication_method(auth_options)
+ auth_options.os_auth_plugin = auth.select_auth_plugin(auth_options)
self._auth_plugin = auth_options.os_auth_plugin
self._url = auth_options.os_url
@@ -68,7 +69,7 @@ class ClientManager(object):
self._service_catalog = None
self.timing = auth_options.timing
- # For compatability until all clients can be updated
+ # For compatibility until all clients can be updated
if 'project_name' in self._auth_params:
self._project_name = self._auth_params['project_name']
elif 'tenant_name' in self._auth_params:
@@ -88,27 +89,25 @@ class ClientManager(object):
root_logger = logging.getLogger('')
LOG.setLevel(root_logger.getEffectiveLevel())
- self.session = None
- if not self._url:
- LOG.debug('Using auth plugin: %s' % self._auth_plugin)
- auth_plugin = base.get_plugin_class(self._auth_plugin)
- self.auth = auth_plugin.load_from_options(**self._auth_params)
- # needed by SAML authentication
- request_session = requests.session()
- self.session = session.Session(
- auth=self.auth,
- session=request_session,
- verify=verify,
- )
+ LOG.debug('Using auth plugin: %s' % self._auth_plugin)
+ auth_plugin = base.get_plugin_class(self._auth_plugin)
+ self.auth = auth_plugin.load_from_options(**self._auth_params)
+ # needed by SAML authentication
+ request_session = requests.session()
+ self.session = session.Session(
+ auth=self.auth,
+ session=request_session,
+ verify=verify,
+ )
self.auth_ref = None
- if not self._auth_plugin.endswith("token") and not self._url:
- LOG.debug("Populate other password flow attributes")
- self.auth_ref = self.session.auth.get_auth_ref(self.session)
- self._token = self.session.auth.get_token(self.session)
+ if 'token' not in self._auth_params:
+ LOG.debug("Get service catalog")
+ self.auth_ref = self.auth.get_auth_ref(self.session)
self._service_catalog = self.auth_ref.service_catalog
- else:
- self._token = self._auth_params.get('token')
+
+ # This begone when clients no longer need it...
+ self._token = self.auth.get_token(self.session)
return