From 4a1afcd3ce3dde34917a134e1fbb254674fd9729 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Mon, 10 Feb 2020 20:20:19 -0600 Subject: [PATCH] Introduce scope_types in os-create-backup oslo.policy introduced the scope_type feature which can control the access level at system-level and project-level. - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html Appropriate scope_type for nova case: - https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope This commit introduce scope_type for os-create-backup API policies as 'system' and 'project'. Also adds the test case with scope_type enabled and verify we pass and fail the policy check with expected context. Partial implement blueprint policy-defaults-refresh Change-Id: I0d526bfffe44b59a75d46e7377e705447a349b04 --- nova/policies/create_backup.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nova/policies/create_backup.py b/nova/policies/create_backup.py index bc4c55f56e..b90016ed5a 100644 --- a/nova/policies/create_backup.py +++ b/nova/policies/create_backup.py @@ -23,15 +23,16 @@ BASE_POLICY_NAME = 'os_compute_api:os-create-backup' create_backup_policies = [ policy.DocumentedRuleDefault( - BASE_POLICY_NAME, - base.RULE_ADMIN_OR_OWNER, - 'Create a back up of a server', - [ + name=BASE_POLICY_NAME, + check_str=base.RULE_ADMIN_OR_OWNER, + description='Create a back up of a server', + operations=[ { 'method': 'POST', 'path': '/servers/{server_id}/action (createBackup)' } - ]) + ], + scope_types=['system', 'project']) ]