aboutsummaryrefslogtreecommitdiffstats
path: root/keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2016-03-04 15:50:10 +0100
committerasteroide <thomas.duval@orange.com>2016-03-04 15:50:10 +0100
commit65ab65faac57b156c4d238afa8de422f52a5a68a (patch)
tree34bc68621f261c9cba4153d5ef9a2ff2ef6449a4 /keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py
parent7be2f3dfff8541051c641e5715d6d70705cab5f7 (diff)
Update KeystoneMiddleware to the stable/liberty version.
Change-Id: I225ed685dad129dc7c1d5d6a00e54c0facde0c07
Diffstat (limited to 'keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py')
-rw-r--r--keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py b/keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py
index 8cc449ad..a68356a8 100644
--- a/keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py
+++ b/keystonemiddleware-moon/keystonemiddleware/auth_token/_revocations.py
@@ -104,3 +104,25 @@ class Revocations(object):
if self._any_revoked(token_ids):
self._log.debug('Token is marked as having been revoked')
raise exc.InvalidToken(_('Token has been revoked'))
+
+ def check_by_audit_id(self, audit_ids):
+ """Check whether the audit_id appears in the revocation list.
+
+ :raises keystonemiddleware.auth_token._exceptions.InvalidToken:
+ if the audit ID(s) appear in the revocation list.
+
+ """
+ revoked_tokens = self._list.get('revoked', None)
+ if not revoked_tokens:
+ # There's no revoked tokens, so nothing to do.
+ return
+
+ # The audit_id may not be present in the revocation events because
+ # earlier versions of the identity server didn't provide them.
+ revoked_ids = set(
+ x['audit_id'] for x in revoked_tokens if 'audit_id' in x)
+ for audit_id in audit_ids:
+ if audit_id in revoked_ids:
+ self._log.debug(
+ 'Token is marked as having been revoked by audit id')
+ raise exc.InvalidToken(_('Token has been revoked'))