Skip to content

Commit 126a22b

Browse files
committed
[S-RBAC] Fix policies for local_ip_association
Policies for those API actions should not rely on the "PROJECT_READER" or "PROJECT_MEMBER" rules as this resource don't have project_id attribute and instead belongs to the project of the parent resource (which is local_ip). This patch updates those rules to: base.ADMIN_OR_PARENT_OWNER_MEMBER base.ADMIN_OR_PARENT_OWNER_READER Closes-bug: #2126576 Change-Id: Ie12c4e40edc09b3477db7c8ffa3067856ea42866 Signed-off-by: Slawek Kaplonski <[email protected]> (cherry picked from commit 8ff3d9d)
1 parent 6cd92e3 commit 126a22b

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

neutron/conf/policies/local_ip_association.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
rules = [
2828
policy.DocumentedRuleDefault(
2929
name='create_local_ip_port_association',
30-
check_str=neutron_policy.policy_or(
31-
base.ADMIN_OR_PROJECT_MEMBER,
32-
base.PARENT_OWNER_MEMBER),
30+
check_str=base.ADMIN_OR_PARENT_OWNER_MEMBER,
3331
scope_types=['project'],
3432
description='Create a Local IP port association',
3533
operations=[
@@ -46,9 +44,7 @@
4644
),
4745
policy.DocumentedRuleDefault(
4846
name='get_local_ip_port_association',
49-
check_str=neutron_policy.policy_or(
50-
base.ADMIN_OR_PROJECT_READER,
51-
base.PARENT_OWNER_READER),
47+
check_str=base.ADMIN_OR_PARENT_OWNER_READER,
5248
scope_types=['project'],
5349
description='Get a Local IP port association',
5450
operations=[
@@ -69,9 +65,7 @@
6965
),
7066
policy.DocumentedRuleDefault(
7167
name='delete_local_ip_port_association',
72-
check_str=neutron_policy.policy_or(
73-
base.ADMIN_OR_PROJECT_MEMBER,
74-
base.PARENT_OWNER_MEMBER),
68+
check_str=base.ADMIN_OR_PARENT_OWNER_MEMBER,
7569
scope_types=['project'],
7670
description='Delete a Local IP port association',
7771
operations=[

neutron/tests/unit/conf/policies/test_local_ip_association.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ def setUp(self):
2828
super().setUp()
2929
self.local_ip = {
3030
'id': uuidutils.generate_uuid(),
31+
'tenant_id': self.project_id,
3132
'project_id': self.project_id}
3233
self.alt_local_ip = {
3334
'id': uuidutils.generate_uuid(),
35+
'tenant_id': self.alt_project_id,
3436
'project_id': self.alt_project_id}
3537

3638
self.target = {
37-
'project_id': self.project_id,
3839
'local_ip_id': self.local_ip['id'],
3940
'ext_parent_local_ip_id': self.local_ip['id']}
4041
self.alt_target = {
41-
'project_id': self.alt_project_id,
4242
'local_ip_id': self.alt_local_ip['id'],
4343
'ext_parent_local_ip_id': self.alt_local_ip['id']}
4444

0 commit comments

Comments
 (0)