| 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 |
|
| 22 |
rules = [ |
| 23 |
policy.RuleDefault( |
| 24 |
name='shared_firewall_policies', |
| 25 |
check_str='field:firewall_policies:shared=True', |
| 26 |
description='Definition of shared firewall policies' |
| 27 |
), |
| 28 |
|
| 29 |
policy.DocumentedRuleDefault( |
| 30 |
name='create_firewall_policy', |
| 31 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 32 |
scope_types=['project'], |
| 33 |
description='Create a firewall policy', |
| 34 |
operations=[ |
| 35 |
{ |
| 36 |
'method': 'POST', |
| 37 |
'path': '/fwaas/firewall_policies', |
| 38 |
}, |
| 39 |
], |
| 40 |
deprecated_rule=policy.DeprecatedRule( |
| 41 |
name='create_firewall_policy', |
| 42 |
check_str=base.RULE_ANY, |
| 43 |
deprecated_reason=DEPRECATED_REASON, |
| 44 |
deprecated_since='2025.2') |
| 45 |
), |
| 46 |
policy.DocumentedRuleDefault( |
| 47 |
name='update_firewall_policy', |
| 48 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 49 |
scope_types=['project'], |
| 50 |
description='Update a firewall policy', |
| 51 |
operations=[ |
| 52 |
{ |
| 53 |
'method': 'PUT', |
| 54 |
'path': '/fwaas/firewall_policies/{id}', |
| 55 |
}, |
| 56 |
], |
| 57 |
deprecated_rule=policy.DeprecatedRule( |
| 58 |
name='update_firewall_policy', |
| 59 |
check_str=base.RULE_ADMIN_OR_OWNER, |
| 60 |
deprecated_reason=DEPRECATED_REASON, |
| 61 |
deprecated_since='2025.2') |
| 62 |
), |
| 63 |
policy.DocumentedRuleDefault( |
| 64 |
name='delete_firewall_policy', |
| 65 |
check_str=neutron_base.ADMIN_OR_PROJECT_MEMBER, |
| 66 |
scope_types=['project'], |
| 67 |
description='Delete a firewall policy', |
| 68 |
operations=[ |
| 69 |
{ |
| 70 |
'method': 'DELETE', |
| 71 |
'path': '/fwaas/firewall_policies/{id}', |
| 72 |
}, |
| 73 |
], |
| 74 |
deprecated_rule=policy.DeprecatedRule( |
| 75 |
name='delete_firewall_policy', |
| 76 |
check_str=base.RULE_ADMIN_OR_OWNER, |
| 77 |
deprecated_reason=DEPRECATED_REASON, |
| 78 |
deprecated_since='2025.2') |
| 79 |
), |
| 80 |
|
| 81 |
policy.DocumentedRuleDefault( |
| 82 |
name='create_firewall_policy:shared', |
| 83 |
check_str=neutron_base.ADMIN, |
| 84 |
scope_types=['project'], |
| 85 |
description='Create a shared firewall policy', |
| 86 |
operations=[ |
| 87 |
{ |
| 88 |
'method': 'POST', |
| 89 |
'path': '/fwaas/firewall_policies', |
| 90 |
}, |
| 91 |
], |
| 92 |
deprecated_rule=policy.DeprecatedRule( |
| 93 |
name='create_firewall_policy:shared', |
| 94 |
check_str=base.RULE_ADMIN_ONLY, |
| 95 |
deprecated_reason=DEPRECATED_REASON, |
| 96 |
deprecated_since='2025.2') |
| 97 |
), |
| 98 |
policy.DocumentedRuleDefault( |
| 99 |
name='update_firewall_policy:shared', |
| 100 |
check_str=neutron_base.ADMIN, |
| 101 |
scope_types=['project'], |
| 102 |
description='Update ``shared`` attribute of a firewall policy', |
| 103 |
operations=[ |
| 104 |
{ |
| 105 |
'method': 'PUT', |
| 106 |
'path': '/fwaas/firewall_policies/{id}', |
| 107 |
}, |
| 108 |
], |
| 109 |
deprecated_rule=policy.DeprecatedRule( |
| 110 |
name='update_firewall_policy:shared', |
| 111 |
check_str=base.RULE_ADMIN_ONLY, |
| 112 |
deprecated_reason=DEPRECATED_REASON, |
| 113 |
deprecated_since='2025.2') |
| 114 |
), |
| 115 |
|
| 116 |
policy.DocumentedRuleDefault( |
| 117 |
name='delete_firewall_policy:shared', |
| 118 |
check_str=neutron_base.ADMIN, |
| 119 |
scope_types=['project'], |
| 120 |
description='Delete a shread firewall policy', |
| 121 |
operations=[ |
| 122 |
{ |
| 123 |
'method': 'DELETE', |
| 124 |
'path': '/fwaas/firewall_policies/{id}', |
| 125 |
}, |
| 126 |
], |
| 127 |
deprecated_rule=policy.DeprecatedRule( |
| 128 |
name='delete_firewall_policy:shared', |
| 129 |
check_str=base.RULE_ADMIN_ONLY, |
| 130 |
deprecated_reason=DEPRECATED_REASON, |
| 131 |
deprecated_since='2025.2') |
| 132 |
), |
| 133 |
|
| 134 |
policy.DocumentedRuleDefault( |
| 135 |
name='get_firewall_policy', |
| 136 |
check_str=base.policy_or( |
| 137 |
neutron_base.ADMIN_OR_PROJECT_READER, |
| 138 |
'rule:shared_firewall_policies'), |
| 139 |
scope_types=['project'], |
| 140 |
description='Get firewall policies', |
| 141 |
operations=[ |
| 142 |
{ |
| 143 |
'method': 'GET', |
| 144 |
'path': '/fwaas/firewall_policies', |
| 145 |
}, |
| 146 |
{ |
| 147 |
'method': 'GET', |
| 148 |
'path': '/fwaas/firewall_policies/{id}', |
| 149 |
}, |
| 150 |
], |
| 151 |
deprecated_rule=policy.DeprecatedRule( |
| 152 |
name='get_firewall_policy', |
| 153 |
check_str='rule:admin_or_owner or rule:shared_firewall_policies', |
| 154 |
deprecated_reason=DEPRECATED_REASON, |
| 155 |
deprecated_since='2025.2') |
| 156 |
), |
| 157 |
] |
| 158 |
|
| 159 |
|
| 160 |
def list_rules(): |
| 161 |
return rules |