Do not require the token_id for converting v3 to v2 tokens

Requiring the token_id as part of the arguments for converting v3 to
v2 tokens results in a more difficult transition to the unification
of the code paths for issuing and validating V2 tokens. This is the
first step in eliminating similar but not-quite the same code paths
for issuing and validating Fernet V2 tokens and all other forms of
V2 tokens.

Change-Id: I348974c8285a1a7b724aee1bfbf2d694d5d77406
This commit is contained in:
Morgan Fainberg 2015-06-28 14:06:43 -07:00 committed by Lance Bragstad
parent e641c40b68
commit 6982dc2fc2
2 changed files with 6 additions and 6 deletions

View File

@ -37,13 +37,12 @@ CONF = cfg.CONF
class V2TokenDataHelper(object):
"""Creates V2 token data."""
def v3_to_v2_token(self, token_id, v3_token_data):
def v3_to_v2_token(self, v3_token_data):
token_data = {}
# Build v2 token
v3_token = v3_token_data['token']
token = {}
token['id'] = token_id
token['expires'] = v3_token.get('expires_at')
token['issued_at'] = v3_token.get('issued_at')
token['audit_ids'] = v3_token.get('audit_ids')

View File

@ -94,8 +94,8 @@ class Provider(common.BaseProvider):
project_id=project_id)
self._build_issued_at_info(token_id, v3_token_data)
# Convert v3 to v2 token data and build v2 catalog
token_data = self.v2_token_data_helper.v3_to_v2_token(token_id,
v3_token_data)
token_data = self.v2_token_data_helper.v3_to_v2_token(v3_token_data)
token_data['access']['token']['id'] = token_id
return token_id, token_data
@ -196,8 +196,9 @@ class Provider(common.BaseProvider):
token=token_ref,
include_catalog=False,
audit_info=audit_ids)
return self.v2_token_data_helper.v3_to_v2_token(token_ref,
v3_token_data)
token_data = self.v2_token_data_helper.v3_to_v2_token(v3_token_data)
token_data['access']['token']['id'] = token_ref
return token_data
def validate_v3_token(self, token):
"""Validate a V3 formatted token.