diff options
author | Jamie Lennox <jlennox@redhat.com> | 2013-08-22 11:05:30 +1000 |
---|---|---|
committer | Morgan Fainberg <m@metacloud.com> | 2013-08-26 03:21:27 -0700 |
commit | 90d161fc3a6b81c86b1948783fa2837333b44732 (patch) | |
tree | b22cd91c300bd07c4fdb73aa0197a0d6c90eb1ab /keystoneclient/access.py | |
parent | b43349a1ad8a5353ec415577723bfa3802582c14 (diff) | |
download | python-keystoneclient-90d161fc3a6b81c86b1948783fa2837333b44732.tar.gz |
Add domain attributes to accessinfo
user_domain_id and project_domain_id are already available, so simply
add an equivalent user_domain_name and project_domain_name if available.
The use of 'default' for v2 tokens is inspired from the default behaviour of
similar functions and what is used in auth_token middleware.
Change-Id: Ia9b345529072ab893d04c7a38fb7ba3acdc28227
Diffstat (limited to 'keystoneclient/access.py')
-rw-r--r-- | keystoneclient/access.py | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/keystoneclient/access.py b/keystoneclient/access.py index 5a10c79..483e893 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -134,10 +134,23 @@ class AccessInfo(dict): @property def user_domain_id(self): """Returns the domain id of the user associated with the authentication - request. + request. + + For v2, it always returns 'default' which may be different from the + Keystone configuration. + + :returns: str + """ + raise NotImplementedError() + + @property + def user_domain_name(self): + """Returns the domain name of the user associated with the + authentication request. + + For v2, it always returns 'Default' which may be different from the + Keystone configuration. - For v2, it always returns 'default' which maybe different from the - Keystone configuration. :returns: str """ raise NotImplementedError() @@ -234,10 +247,23 @@ class AccessInfo(dict): @property def project_domain_id(self): """Returns the domain id of the project associated with the - authentication request. + authentication request. + + For v2, it returns 'default' if a project is scoped or None which may + be different from the keystone configuration. + + :returns: str + """ + raise NotImplementedError() + + @property + def project_domain_name(self): + """Returns the domain name of the project associated with the + authentication request. + + For v2, it returns 'Default' if a project is scoped or None which may + be different from the keystone configuration. - For v2, it always returns 'default' which maybe different from the - keystone configuration. :returns: str """ raise NotImplementedError() @@ -318,6 +344,10 @@ class AccessInfoV2(AccessInfo): return 'default' @property + def user_domain_name(self): + return 'Default' + + @property def domain_name(self): return None @@ -397,6 +427,11 @@ class AccessInfoV2(AccessInfo): return 'default' @property + def project_domain_name(self): + if self.project_id: + return 'Default' + + @property def auth_url(self): if self.service_catalog: return self.service_catalog.get_urls(service_type='identity', @@ -457,6 +492,10 @@ class AccessInfoV3(AccessInfo): return self['user']['domain']['id'] @property + def user_domain_name(self): + return self['user']['domain']['name'] + + @property def username(self): return self['user']['name'] @@ -485,6 +524,12 @@ class AccessInfoV3(AccessInfo): return project['domain']['id'] @property + def project_domain_name(self): + project = self.get('project') + if project: + return project['domain']['name'] + + @property def project_name(self): project = self.get('project') if project: |