Skip to content

Commit

Permalink
Fix revoking domain-scoped tokens
Browse files Browse the repository at this point in the history
A token scoped to a domain wouldn't be revoked for a domain-wide
revocation event. This is because the code to convert a token to a
dict for revocation event processing didn't handle domain-scoped
tokens.

Partial-Bug: #1349597

Change-Id: Ib2c58f3fc8790dbe7f8b073d18d3fa9b0dff608d
(cherry picked from commit 3e035eb)
  • Loading branch information
Brant Knudson committed Aug 5, 2014
1 parent cccc3f3 commit 317f9d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion keystone/contrib/revoke/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ def build_token_values(token_data):
token_values['assignment_domain_id'] = project['domain']['id']
else:
token_values['project_id'] = None
token_values['assignment_domain_id'] = None

domain = token_data.get('domain')
if domain is not None:
token_values['assignment_domain_id'] = domain['id']
else:
token_values['assignment_domain_id'] = None

role_list = []
roles = token_data.get('roles')
Expand Down
16 changes: 12 additions & 4 deletions keystone/tests/test_revoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,19 @@ def test_by_domain_project(self):
def test_by_domain_domain(self):
# If revoke a domain, then a token scoped to the domain is revoked.

# FIXME(blk-u): The token translation code doesn't handle domain-scoped
# tokens at this point. See bug #1347318. Replace this with test code
# similar to test_by_domain_project().
user_id = _new_id()
user_domain_id = _new_id()

domain_id = _new_id()

pass
token_data = _sample_blank_token()
token_data['user_id'] = user_id
token_data['identity_domain_id'] = user_domain_id
token_data['assignment_domain_id'] = domain_id

self._revoke_by_domain(domain_id)

self._assertTokenRevoked(token_data)

def _assertEmpty(self, collection):
return self.assertEqual(0, len(collection), "collection not empty")
Expand Down

0 comments on commit 317f9d3

Please sign in to comment.