summaryrefslogtreecommitdiff
path: root/openstackclient/identity/v2_0/token.py
diff options
context:
space:
mode:
authorNavid Pustchi <npustchi@gmail.com>2016-02-04 16:45:38 +0000
committerAlvaro Lopez Garcia <aloga@ifca.unican.es>2016-06-09 18:00:40 +0200
commit6ae0d2e8a54fd5139e63a990ab4bdce634e73c5e (patch)
tree5833e88147e71524b49a5b25979fd17869dd455c /openstackclient/identity/v2_0/token.py
parentada6abb30e6b1c49229817ae53ab96d88c50fd21 (diff)
downloadpython-openstackclient-6ae0d2e8a54fd5139e63a990ab4bdce634e73c5e.tar.gz
Moving authentication from keystoneclient to keystoneauth
Currently OpenStackClient uses keystoneclient for authentication. This change will update OpenStackClient to use keystoneauth for authentication. All dependant test have been updated. Updating how auth_ref is set in the tests to use KSA fixtures had some racy side-effects. The user_role_list tests failed when they picked up an auth_ref that was a fixture. This exposed a weakness in ListUserRole that needed to be fixed at the same time re handling of unscoped tokens and options. Change-Id: I4ddb2dbbb3bf2ab37494468eaf65cef9213a6e00 Closes-Bug: 1533369
Diffstat (limited to 'openstackclient/identity/v2_0/token.py')
-rw-r--r--openstackclient/identity/v2_0/token.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/openstackclient/identity/v2_0/token.py b/openstackclient/identity/v2_0/token.py
index f435d7ce..d708749d 100644
--- a/openstackclient/identity/v2_0/token.py
+++ b/openstackclient/identity/v2_0/token.py
@@ -18,6 +18,7 @@
import six
from openstackclient.common import command
+from openstackclient.common import exceptions
from openstackclient.i18n import _
@@ -32,11 +33,21 @@ class IssueToken(command.ShowOne):
return parser
def take_action(self, parsed_args):
+ auth_ref = self.app.client_manager.auth_ref
+ if not auth_ref:
+ raise exceptions.AuthorizationFailure(
+ "Only an authorized user may issue a new token.")
- token = self.app.client_manager.auth_ref.service_catalog.get_token()
- if 'tenant_id' in token:
- token['project_id'] = token.pop('tenant_id')
- return zip(*sorted(six.iteritems(token)))
+ data = {}
+ if auth_ref.auth_token:
+ data['id'] = auth_ref.auth_token
+ if auth_ref.expires:
+ data['expires'] = auth_ref.expires
+ if auth_ref.project_id:
+ data['project_id'] = auth_ref.project_id
+ if auth_ref.user_id:
+ data['user_id'] = auth_ref.user_id
+ return zip(*sorted(six.iteritems(data)))
class RevokeToken(command.Command):