Support older token formats for projects in accessinfo
Older token formats get decoded as a v2 token so we should support reading project information from these tokens. Change-Id: I31473a00b294bd0d7b535cfab8d2eaf09db97ff5
This commit is contained in:
parent
4775abf753
commit
fae4e38f61
@ -222,7 +222,7 @@ class AccessInfo(dict):
|
||||
request, or None if the authentication request wasn't scoped to a
|
||||
project.
|
||||
|
||||
:returns: str or None ((if no project associated with the token)
|
||||
:returns: str or None (if no project associated with the token)
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -327,9 +327,24 @@ class AccessInfoV2(AccessInfo):
|
||||
|
||||
@property
|
||||
def project_name(self):
|
||||
tenant_dict = self['token'].get('tenant', None)
|
||||
if tenant_dict:
|
||||
return tenant_dict.get('name', None)
|
||||
try:
|
||||
tenant_dict = self['token']['tenant']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
return tenant_dict.get('name')
|
||||
|
||||
# pre grizzly
|
||||
try:
|
||||
return self['user']['tenantName']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# pre diablo, keystone only provided a tenantId
|
||||
try:
|
||||
return self['token']['tenantId']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@property
|
||||
def scoped(self):
|
||||
@ -357,10 +372,24 @@ class AccessInfoV2(AccessInfo):
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
tenant_dict = self['token'].get('tenant', None)
|
||||
if tenant_dict:
|
||||
return tenant_dict.get('id', None)
|
||||
return None
|
||||
try:
|
||||
tenant_dict = self['token']['tenant']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
return tenant_dict.get('id')
|
||||
|
||||
# pre grizzly
|
||||
try:
|
||||
return self['user']['tenantId']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# pre diablo
|
||||
try:
|
||||
return self['token']['tenantId']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@property
|
||||
def project_domain_id(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user