diff options
author | Colleen Murphy <colleen.murphy@suse.de> | 2019-08-11 21:06:36 -0700 |
---|---|---|
committer | Colleen Murphy <colleen.murphy@suse.de> | 2019-08-16 15:10:49 -0700 |
commit | 0df8d0e2e1519154ec76100f7a4c2fdc8c9c04bb (patch) | |
tree | 9bbc81510be7d47f335aeb2a4be1df9f3259952f /keystone/tests/unit/test_policy.py | |
parent | 5086709ae2d673716653cd8812247ea5a1cb5e69 (diff) | |
download | keystone-0df8d0e2e1519154ec76100f7a4c2fdc8c9c04bb.tar.gz |
Move list_trusts enforcement to default policies
Without this change, policy enforcement for the GET /OS-TRUST/trusts API
is hardcoded in the flask dispatcher code. This is a problem because
this enforcement can't be controlled by the operator, as is the norm.
Moreover, it makes the transition to system-scope and
default-roles-aware policies more difficult because there's no sensible
migration from "" to a logical role-based check string.
This patch starts the conversion from hardcoded enforcement to
enforcement via default policies for GET /OS-TRUST/trusts. To do this,
we add two new policy rules, "identity:list_trusts_for_trustor" and
"identity:list_trusts_for_trustee". We need to do this so that we can
keep backwards compatibility with the bizarre behavior that an admin can
list all trusts (GET /OS-TRUST/trusts) but not list trusts for a trustor
or trustee (GET /OS-TRUST/trusts?trustor_user_id={} and
GET/OS-TRUST/trusts?trustee_user_id={}). The tricky part is that it's
plausible that operators may have incorporated the hardcoded empty
default for "identity:list_trusts" into their on-disk policy
configuration, either by never removing the old default policy file that
used to come packaged with keystone, or by generating a sample file and
applying that to disk (we don't recommend that but we don't expressly
forbid or discourage it either). To overcome
this, the trust API code checks whether the "identity:list_trusts" rule
is "" and re-applies the enforcement with a warning. We don't need to do
this for the two new policies because they are initially enforced
in-code and an operator would have to take explicit action on upgrade to
override them.
This change does not use the formal oslo.policy deprecation system
because "" OR'd with the new default is entirely useless as a policy.
Partial-bug: #1818850
Partial-bug: #1818846
Change-Id: I6c1a4ecd756519f7f807c9d28960482e7f0d235b
Diffstat (limited to 'keystone/tests/unit/test_policy.py')
-rw-r--r-- | keystone/tests/unit/test_policy.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/keystone/tests/unit/test_policy.py b/keystone/tests/unit/test_policy.py index db8db5ffd..663e886fe 100644 --- a/keystone/tests/unit/test_policy.py +++ b/keystone/tests/unit/test_policy.py @@ -194,6 +194,8 @@ class PolicyJsonTestCase(unit.TestCase): 'identity:revocation_list', 'identity:create_trust', 'identity:list_trusts', + 'identity:list_trusts_for_trustor', + 'identity:list_trusts_for_trustee', 'identity:list_roles_for_trust', 'identity:get_role_for_trust', 'identity:delete_trust', |