diff options
| author | Jamie Lennox <jamielennox@redhat.com> | 2014-03-21 14:39:13 +1000 |
|---|---|---|
| committer | Jamie Lennox <jamielennox@redhat.com> | 2014-06-09 23:43:16 +0000 |
| commit | 320fa59f13c9b31c96409f5fb38ecd76920e119e (patch) | |
| tree | 3e7aeaa8d80e7932c70707aa1d40b4eb2b054502 /keystoneclient/v2_0/client.py | |
| parent | 53a175e7c6aca860f9a9eaa4af6d9801d0cfdba4 (diff) | |
| download | python-keystoneclient-320fa59f13c9b31c96409f5fb38ecd76920e119e.tar.gz | |
Remove _factory methods from auth plugins
This was a simple factory that would give compatibility for the existing
client to load up the appropriate auth plugin. A more robust plugin
loading mechanism is coming for this and having it available encourages
other auth plugins that they should be using that where they shouldn't.
Just remove it from the auth plugin class. It shouldn't be used by
anyone else so lets keep it on the client objects.
Blueprint: plugin-params
Change-Id: I0618b646f302300d41c7dd7153a1c0bdc237a745
Diffstat (limited to 'keystoneclient/v2_0/client.py')
| -rw-r--r-- | keystoneclient/v2_0/client.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/keystoneclient/v2_0/client.py b/keystoneclient/v2_0/client.py index 8dcd778..0d4e685 100644 --- a/keystoneclient/v2_0/client.py +++ b/keystoneclient/v2_0/client.py @@ -153,6 +153,9 @@ class Client(httpclient.HTTPClient): **kwargs): """Authenticate against the v2 Identity API. + If a token is provided it will be used in preference over username and + password. + :returns: access.AccessInfo if authentication was successful. :raises: AuthorizationFailure if unable to authenticate or validate the existing authorization token @@ -161,15 +164,20 @@ class Client(httpclient.HTTPClient): if auth_url is None: raise ValueError("Cannot authenticate without an auth_url") - a = v2_auth.Auth._factory(auth_url, - username=username, - password=password, - token=token, - trust_id=trust_id, - tenant_id=project_id or tenant_id, - tenant_name=project_name or tenant_name) + new_kwargs = {'trust_id': trust_id, + 'tenant_id': project_id or tenant_id, + 'tenant_name': project_name or tenant_name} + + if token: + plugin = v2_auth.Token(auth_url, token, **new_kwargs) + elif username and password: + plugin = v2_auth.Password(auth_url, username, password, + **new_kwargs) + else: + msg = 'A username and password or token is required.' + raise exceptions.AuthorizationFailure(msg) - return a.get_auth_ref(self.session) + return plugin.get_auth_ref(self.session) except (exceptions.AuthorizationFailure, exceptions.Unauthorized): _logger.debug("Authorization Failed.") raise |
