c4618857b0
This patch should finally complete phase 1 of Secure RBAC community goal [1] where it was agreed that there will be just 4 personas: * ADMIN * PROJECT_ADMIN * PROJECT_MEMBER * PROJECT_READER System scope personas will be added in next phases of the community goal. To complete phase 1 in Neutron, this patch removes hardcoded system scope from the check strings in system scope personas - that way it can be controlled by the config option and enforced by oslo_policy only when enabled. It also skips all SYSTEM_MEMBER and SYSTEM_READER related unit tests. We can re-enable them in the future where we will have those personas working in Neutron. [1] https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html#phase-1 Change-Id: Iafa8ec1d9710ff404450ad0a64baf56a0f993756
222 lines
7.1 KiB
Python
222 lines
7.1 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from oslo_log import versionutils
|
|
from oslo_policy import policy
|
|
|
|
from neutron.conf.policies import base
|
|
|
|
|
|
COLLECTION_PATH = '/agents'
|
|
RESOURCE_PATH = '/agents/{id}'
|
|
|
|
DEPRECATION_REASON = (
|
|
"The Agent API now supports system scope and default roles.")
|
|
|
|
rules = [
|
|
policy.DocumentedRuleDefault(
|
|
name='get_agent',
|
|
check_str=base.ADMIN,
|
|
description='Get an agent',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': COLLECTION_PATH,
|
|
},
|
|
{
|
|
'method': 'GET',
|
|
'path': RESOURCE_PATH,
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='get_agent',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='update_agent',
|
|
check_str=base.ADMIN,
|
|
description='Update an agent',
|
|
operations=[
|
|
{
|
|
'method': 'PUT',
|
|
'path': RESOURCE_PATH,
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='update_agent',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='delete_agent',
|
|
check_str=base.ADMIN,
|
|
description='Delete an agent',
|
|
operations=[
|
|
{
|
|
'method': 'DELETE',
|
|
'path': RESOURCE_PATH,
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='delete_agent',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='create_dhcp-network',
|
|
check_str=base.ADMIN,
|
|
description='Add a network to a DHCP agent',
|
|
operations=[
|
|
{
|
|
'method': 'POST',
|
|
'path': '/agents/{agent_id}/dhcp-networks',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='create_dhcp-network',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='get_dhcp-networks',
|
|
check_str=base.ADMIN,
|
|
description='List networks on a DHCP agent',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/agents/{agent_id}/dhcp-networks',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='get_dhcp-networks',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='delete_dhcp-network',
|
|
check_str=base.ADMIN,
|
|
description='Remove a network from a DHCP agent',
|
|
operations=[
|
|
{
|
|
'method': 'DELETE',
|
|
'path': '/agents/{agent_id}/dhcp-networks/{network_id}',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='delete_dhcp-network',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='create_l3-router',
|
|
check_str=base.ADMIN,
|
|
description='Add a router to an L3 agent',
|
|
operations=[
|
|
{
|
|
'method': 'POST',
|
|
'path': '/agents/{agent_id}/l3-routers',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='create_l3-router',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='get_l3-routers',
|
|
check_str=base.ADMIN,
|
|
description='List routers on an L3 agent',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/agents/{agent_id}/l3-routers',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='get_l3-routers',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='delete_l3-router',
|
|
check_str=base.ADMIN,
|
|
description='Remove a router from an L3 agent',
|
|
operations=[
|
|
{
|
|
'method': 'DELETE',
|
|
'path': '/agents/{agent_id}/l3-routers/{router_id}',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='delete_l3-router',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='get_dhcp-agents',
|
|
check_str=base.ADMIN,
|
|
description='List DHCP agents hosting a network',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/networks/{network_id}/dhcp-agents',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='get_dhcp-agents',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name='get_l3-agents',
|
|
check_str=base.ADMIN,
|
|
description='List L3 agents hosting a router',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/routers/{router_id}/l3-agents',
|
|
},
|
|
],
|
|
scope_types=['system'],
|
|
deprecated_rule=policy.DeprecatedRule(
|
|
name='get_l3-agents',
|
|
check_str=base.RULE_ADMIN_ONLY,
|
|
deprecated_reason=DEPRECATION_REASON,
|
|
deprecated_since=versionutils.deprecated.WALLABY)
|
|
),
|
|
]
|
|
|
|
|
|
def list_rules():
|
|
return rules
|