Merge "Implement secure RBAC for share types"
This commit is contained in:
commit
39dbe2cb0f
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import versionutils
|
||||
from oslo_policy import policy
|
||||
|
||||
from manila.policies import base
|
||||
@ -20,40 +21,98 @@ from manila.policies import base
|
||||
|
||||
BASE_POLICY_NAME = 'share_type:%s'
|
||||
|
||||
DEPRECATED_REASON = """
|
||||
The share type API now supports system scope and default roles.
|
||||
"""
|
||||
|
||||
deprecated_share_type_create = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'create',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
deprecated_share_type_update = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'update',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
deprecated_share_type_show = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'show',
|
||||
check_str=base.RULE_DEFAULT
|
||||
)
|
||||
deprecated_share_type_index = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'index',
|
||||
check_str=base.RULE_DEFAULT
|
||||
)
|
||||
deprecated_share_type_get_default = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'default',
|
||||
check_str=base.RULE_DEFAULT
|
||||
)
|
||||
deprecated_share_type_delete = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'delete',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
deprecated_share_type_list_project_access = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'list_project_access',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
deprecated_share_type_add_project_access = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'add_project_access',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
deprecated_share_type_remove_project_access = policy.DeprecatedRule(
|
||||
name=BASE_POLICY_NAME % 'remove_project_access',
|
||||
check_str=base.RULE_ADMIN_API
|
||||
)
|
||||
|
||||
|
||||
share_type_policies = [
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'create',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description='Create share type.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'POST',
|
||||
'path': '/types',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_create,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'update',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description='Update share type.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'PUT',
|
||||
'path': '/types/{share_type_id}',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_update,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'show',
|
||||
check_str=base.RULE_DEFAULT,
|
||||
check_str=base.SYSTEM_OR_PROJECT_READER,
|
||||
scope_types=['system', 'project'],
|
||||
description='Get share type.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'GET',
|
||||
'path': '/types/{share_type_id}',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_show,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'index',
|
||||
check_str=base.RULE_DEFAULT,
|
||||
check_str=base.SYSTEM_OR_PROJECT_READER,
|
||||
scope_types=['system', 'project'],
|
||||
description='List share types.',
|
||||
operations=[
|
||||
{
|
||||
@ -64,57 +123,86 @@ share_type_policies = [
|
||||
'method': 'GET',
|
||||
'path': '/types?is_public=all',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_index,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'default',
|
||||
check_str=base.RULE_DEFAULT,
|
||||
check_str=base.SYSTEM_OR_PROJECT_READER,
|
||||
scope_types=['system', 'project'],
|
||||
description='Get default share type.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'GET',
|
||||
'path': '/types/default',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_get_default,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'delete',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description='Delete share type.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'DELETE',
|
||||
'path': '/types/{share_type_id}',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_delete,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'list_project_access',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_READER,
|
||||
scope_types=['system'],
|
||||
description='List share type project access.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'GET',
|
||||
'path': '/types/{share_type_id}',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_list_project_access,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'add_project_access',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description='Add share type to project.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'POST',
|
||||
'path': '/types/{share_type_id}/action',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_add_project_access,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name=BASE_POLICY_NAME % 'remove_project_access',
|
||||
check_str=base.RULE_ADMIN_API,
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description='Remove share type from project.',
|
||||
operations=[
|
||||
{
|
||||
'method': 'POST',
|
||||
'path': '/types/{share_type_id}/action',
|
||||
}
|
||||
]),
|
||||
],
|
||||
deprecated_rule=deprecated_share_type_remove_project_access,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user