From 0740766467a3c8de0bf9d03689158a86591bd506 Mon Sep 17 00:00:00 2001 From: Jaspinder Date: Mon, 4 Jan 2016 05:08:41 -0600 Subject: [PATCH] fix: can't get authentication with os-token and os-url Currently, there is no way to authenticate a user through Neutron CLI by just using endpoint and token authentication. This simple fix will at least allow for that to be permitted. Change-Id: Ia7d285af224ef225aa20f83d7d4c87b81aac58ed Closes-Bug: 1450414 --- neutronclient/shell.py | 21 +++++++++++++++---- ...ndpoint-auth-support-26bf7ee12e4ec833.yaml | 7 +++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/add-token-endpoint-auth-support-26bf7ee12e4ec833.yaml diff --git a/neutronclient/shell.py b/neutronclient/shell.py index 5261a349e..64de864af 100644 --- a/neutronclient/shell.py +++ b/neutronclient/shell.py @@ -898,11 +898,22 @@ class NeutronShell(app.App): cloud=self.options.os_cloud, argparse=self.options, network_api_version=self.api_version) verify, cert = cloud_config.get_requests_verify_args() - auth = cloud_config.get_auth() - auth_session = session.Session( - auth=auth, verify=verify, cert=cert, - timeout=self.options.http_timeout) + # TODO(singhj): Remove dependancy on HTTPClient + # for the case of token-endpoint authentication + + # When using token-endpoint authentication legacy + # HTTPClient will be used, otherwise SessionClient + # will be used. + if self.options.os_token and self.options.os_url: + auth = None + auth_session = None + else: + auth = cloud_config.get_auth() + + auth_session = session.Session( + auth=auth, verify=verify, cert=cert, + timeout=self.options.http_timeout) interface = self.options.os_endpoint_type or self.endpoint_type if interface.endswith('URL'): @@ -911,6 +922,8 @@ class NeutronShell(app.App): retries=self.options.retries, raise_errors=False, session=auth_session, + url=self.options.os_url, + token=self.options.os_token, region_name=cloud_config.get_region_name(), api_version=cloud_config.get_api_version('network'), service_type=cloud_config.get_service_type('network'), diff --git a/releasenotes/notes/add-token-endpoint-auth-support-26bf7ee12e4ec833.yaml b/releasenotes/notes/add-token-endpoint-auth-support-26bf7ee12e4ec833.yaml new file mode 100644 index 000000000..d3445cde0 --- /dev/null +++ b/releasenotes/notes/add-token-endpoint-auth-support-26bf7ee12e4ec833.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + CLI support for token-endpoint authentication. + + * Allows for authentication via ``--os-token`` and ``--os-url`` options + or the ``OS_TOKEN`` and ``OS_URL`` environment variables, respectively