diff options
author | Jamie Lennox <jamielennox@redhat.com> | 2015-03-27 14:03:20 +1100 |
---|---|---|
committer | Jamie Lennox <jamielennox@redhat.com> | 2015-03-28 14:33:15 +1100 |
commit | dfc90092a797d35a235a70f5df9eaba5b4778203 (patch) | |
tree | 7168f8f65b24a7173e5f8925f70b7c78223e8e25 /keystoneclient/access.py | |
parent | a84b5ac115dd5775f7380a204811aa939fd5c242 (diff) | |
download | python-keystoneclient-dfc90092a797d35a235a70f5df9eaba5b4778203.tar.gz |
Expose audit_id via AccessInfo
The audit_id is now a standard part of the v2 and v3 tokens. Expose it
via AccessInfo so that it is usable for services and middleware.
Change-Id: I14ddcfee5434084ad9da73c384e6f456602fdd2b
Closes-Bug: #1437129
Diffstat (limited to 'keystoneclient/access.py')
-rw-r--r-- | keystoneclient/access.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/keystoneclient/access.py b/keystoneclient/access.py index 8217de8..009b72e 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -400,6 +400,35 @@ class AccessInfo(dict): """ raise NotImplementedError() + @property + def audit_id(self): + """Return the audit ID if present. + + :returns: str or None. + """ + raise NotImplementedError() + + @property + def audit_chain_id(self): + """Return the audit chain ID if present. + + In the event that a token was rescoped then this ID will be the + :py:attr:`audit_id` of the initial token. Returns None if no value + present. + + :returns: str or None. + """ + raise NotImplementedError() + + @property + def initial_audit_id(self): + """The audit ID of the initially requested token. + + This is the :py:attr:`audit_chain_id` if present or the + :py:attr:`audit_id`. + """ + return self.audit_chain_id or self.audit_id + class AccessInfoV2(AccessInfo): """An object for encapsulating a raw v2 auth token from identity @@ -592,6 +621,20 @@ class AccessInfoV2(AccessInfo): def is_federated(self): return False + @property + def audit_id(self): + try: + return self['token'].get('audit_ids', [])[0] + except IndexError: + return None + + @property + def audit_chain_id(self): + try: + return self['token'].get('audit_ids', [])[1] + except IndexError: + return None + class AccessInfoV3(AccessInfo): """An object for encapsulating a raw v3 auth token from identity @@ -760,3 +803,17 @@ class AccessInfoV3(AccessInfo): @property def oauth_consumer_id(self): return self.get('OS-OAUTH1', {}).get('consumer_id') + + @property + def audit_id(self): + try: + return self.get('audit_ids', [])[0] + except IndexError: + return None + + @property + def audit_chain_id(self): + try: + return self.get('audit_ids', [])[1] + except IndexError: + return None |