| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
from neutron.conf.policies import base as neutron_base |
| 14 |
from neutron_lib import policy as base |
| 15 |
from oslo_policy import policy |
| 16 |
|
| 17 |
DEPRECATED_REASON = """ |
| 18 |
The FWaaS API now supports Secure RBAC default roles. |
| 19 |
""" |
| 20 |
|
| 21 |
rules = [ |
| 22 |
policy.RuleDefault( |
| 23 |
name='shared_firewall_groups', |
| 24 |
check_str='field:firewall_groups:shared=True', |
| 25 |
description='Definition of shared firewall groups' |
| 26 |
), |
| 27 |
|
| 28 |
policy.DocumentedRuleDefault( |
| 29 |
name='create_firewall_group', |
| 30 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 31 |
scope_types=['project'], |
| 32 |
description='Create a firewall group', |
| 33 |
operations=[ |
| 34 |
{ |
| 35 |
'method': 'POST', |
| 36 |
'path': '/fwaas/firewall_groups', |
| 37 |
}, |
| 38 |
], |
| 39 |
deprecated_rule=policy.DeprecatedRule( |
| 40 |
name='create_firewall_group', |
| 41 |
check_str=base.RULE_ANY, |
| 42 |
deprecated_reason=DEPRECATED_REASON, |
| 43 |
deprecated_since='2025.2') |
| 44 |
), |
| 45 |
policy.DocumentedRuleDefault( |
| 46 |
name='update_firewall_group', |
| 47 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 48 |
scope_types=['project'], |
| 49 |
description='Update a firewall group', |
| 50 |
operations=[ |
| 51 |
{ |
| 52 |
'method': 'PUT', |
| 53 |
'path': '/fwaas/firewall_groups/{id}', |
| 54 |
}, |
| 55 |
], |
| 56 |
deprecated_rule=policy.DeprecatedRule( |
| 57 |
name='update_firewall_group', |
| 58 |
check_str=base.RULE_ADMIN_OR_OWNER, |
| 59 |
deprecated_reason=DEPRECATED_REASON, |
| 60 |
deprecated_since='2025.2') |
| 61 |
), |
| 62 |
policy.DocumentedRuleDefault( |
| 63 |
name='delete_firewall_group', |
| 64 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 65 |
scope_types=['project'], |
| 66 |
description='Delete a firewall group', |
| 67 |
operations=[ |
| 68 |
{ |
| 69 |
'method': 'DELETE', |
| 70 |
'path': '/fwaas/firewall_groups/{id}', |
| 71 |
}, |
| 72 |
], |
| 73 |
deprecated_rule=policy.DeprecatedRule( |
| 74 |
name='delete_firewall_group', |
| 75 |
check_str=base.RULE_ADMIN_OR_OWNER, |
| 76 |
deprecated_reason=DEPRECATED_REASON, |
| 77 |
deprecated_since='2025.2') |
| 78 |
), |
| 79 |
|
| 80 |
policy.DocumentedRuleDefault( |
| 81 |
name='create_firewall_group:shared', |
| 82 |
check_str=neutron_base.ADMIN, |
| 83 |
scope_types=['project'], |
| 84 |
description='Create a shared firewall group', |
| 85 |
operations=[ |
| 86 |
{ |
| 87 |
'method': 'POST', |
| 88 |
'path': '/fwaas/firewall_groups', |
| 89 |
}, |
| 90 |
], |
| 91 |
deprecated_rule=policy.DeprecatedRule( |
| 92 |
name='create_firewall_group:shared', |
| 93 |
check_str=base.RULE_ADMIN_ONLY, |
| 94 |
deprecated_reason=DEPRECATED_REASON, |
| 95 |
deprecated_since='2025.2') |
| 96 |
), |
| 97 |
policy.DocumentedRuleDefault( |
| 98 |
name='update_firewall_group:shared', |
| 99 |
check_str=neutron_base.ADMIN, |
| 100 |
scope_types=['project'], |
| 101 |
description='Update ``shared`` attribute of a firewall group', |
| 102 |
operations=[ |
| 103 |
{ |
| 104 |
'method': 'PUT', |
| 105 |
'path': '/fwaas/firewall_groups/{id}', |
| 106 |
}, |
| 107 |
], |
| 108 |
deprecated_rule=policy.DeprecatedRule( |
| 109 |
name='update_firewall_group:shared', |
| 110 |
check_str=base.RULE_ADMIN_ONLY, |
| 111 |
deprecated_reason=DEPRECATED_REASON, |
| 112 |
deprecated_since='2025.2') |
| 113 |
), |
| 114 |
|
| 115 |
policy.DocumentedRuleDefault( |
| 116 |
name='delete_firewall_group:shared', |
| 117 |
check_str=neutron_base.ADMIN, |
| 118 |
scope_types=['project'], |
| 119 |
description='Delete a shared firewall group', |
| 120 |
operations=[ |
| 121 |
{ |
| 122 |
'method': 'DELETE', |
| 123 |
'path': '/fwaas/firewall_groups/{id}', |
| 124 |
}, |
| 125 |
], |
| 126 |
deprecated_rule=policy.DeprecatedRule( |
| 127 |
name='delete_firewall_group:shared', |
| 128 |
check_str=base.RULE_ADMIN_ONLY, |
| 129 |
deprecated_reason=DEPRECATED_REASON, |
| 130 |
deprecated_since='2025.2') |
| 131 |
), |
| 132 |
|
| 133 |
policy.DocumentedRuleDefault( |
| 134 |
name='get_firewall_group', |
| 135 |
check_str=base.policy_or( |
| 136 |
neutron_base.ADMIN_OR_PROJECT_READER, |
| 137 |
'rule:shared_firewall_groups'), |
| 138 |
scope_types=['project'], |
| 139 |
description='Get firewall groups', |
| 140 |
operations=[ |
| 141 |
{ |
| 142 |
'method': 'GET', |
| 143 |
'path': '/fwaas/firewall_groups', |
| 144 |
}, |
| 145 |
{ |
| 146 |
'method': 'GET', |
| 147 |
'path': '/fwaas/firewall_groups/{id}', |
| 148 |
}, |
| 149 |
], |
| 150 |
deprecated_rule=policy.DeprecatedRule( |
| 151 |
name='get_firewall_group', |
| 152 |
check_str='rule:admin_or_owner or rule:shared_firewall_groups', |
| 153 |
deprecated_reason=DEPRECATED_REASON, |
| 154 |
deprecated_since='2025.2') |
| 155 |
), |
| 156 |
] |
| 157 |
|
| 158 |
|
| 159 |
def list_rules(): |
| 160 |
return rules |