diff options
author | Colleen Murphy <colleen.murphy@suse.com> | 2020-04-16 20:35:46 -0700 |
---|---|---|
committer | Lance Bragstad <lbragstad@gmail.com> | 2020-05-14 13:36:17 +0000 |
commit | fac58fdfbe31a5b93ef65b70927b3df632c689c9 (patch) | |
tree | 2313382440685a4792622a4a67d6fa5c2b1e3ce0 | |
parent | b25739fa9605cc54bc98325c2a92360ba702e8d8 (diff) | |
download | keystone-fac58fdfbe31a5b93ef65b70927b3df632c689c9.tar.gz |
Ensure OAuth1 authorized roles are respected
Without this patch, when an OAuth1 request token is authorized with a
limited set of roles, the roles for the access token are ignored when
the user uses it to request a keystone token. This means that user of an
access token can use it to escallate their role assignments beyond what
was authorized by the creator. This patch fixes the issue by ensuring
the token model accounts for an OAuth1-scoped token and correctly
populating the roles for it.
Modified to work with older test helper function:
keystone/tests/unit/test_v3_oauth1.py
Conflicts:
keystone/models/token_model.py
The keystone token model was refactored in the Rocky release. This
commit only backports the test so that we have test coverage against
the bug and proves there wasn't a regression in Queens. As such, the
code changes to token_model.py (where the bug was introduced) are not
applicable to Queens.
releasenotes/notes/bug-1873290-ff7f8e4cee15b75a.yaml
Removed the release note since there isn't anything to signal to
operators regarding a vulnerability. We're only adding test coverage
to prove that stable/queens isn't vulnerable.
Change-Id: I02f9836fbd4d7e629653977fc341476cfd89859e
Closes-bug: #1873290
(cherry picked from commit 6c73690f779a42a5c62914b6bc37f0ac2f41a3e3)
(cherry picked from commit ba89d27793c2d3a26ad95642660fa9bd820ed3be)
(cherry picked from commit 5ff52dbaa2082991d229d8557a8e4b65256d6c53)
(cherry picked from commit 2483a578a80a916d9f5acd672d85830385b236e2)
(cherry picked from commit 10bc689a6796f85c44d19e0c18f0e37b0a87474c)
-rw-r--r-- | keystone/tests/unit/test_v3_oauth1.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/keystone/tests/unit/test_v3_oauth1.py b/keystone/tests/unit/test_v3_oauth1.py index 096640787..a6876898b 100644 --- a/keystone/tests/unit/test_v3_oauth1.py +++ b/keystone/tests/unit/test_v3_oauth1.py @@ -311,6 +311,19 @@ class OAuthFlowTests(OAuth1Tests): self.keystone_token = content.result['token'] self.assertIsNotNone(self.keystone_token_id) + # add a new role assignment to ensure it is ignored in the access token + new_role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex} + PROVIDERS.role_api.create_role(new_role['id'], new_role) + PROVIDERS.assignment_api.add_role_to_user_and_project( + user_id=self.user_id, + tenant_id=self.project_id, + role_id=new_role['id']) + content = self.post(url, headers=headers, body=body) + token = content.result['token'] + token_roles = [r['id'] for r in token['roles']] + self.assertIn(self.role_id, token_roles) + self.assertNotIn(new_role['id'], token_roles) + class AccessTokenCRUDTests(OAuthFlowTests): def test_delete_access_token_dne(self): |