Merge "Implement policy in code - member (7)"

This commit is contained in:
Zuul 2017-12-01 14:59:42 +00:00 committed by Gerrit Code Review
commit 2290fe8a3b
4 changed files with 86 additions and 13 deletions

View File

@ -1,12 +1,6 @@
{
"default": "rule:admin_or_owner",
"members:create": "rule:admin_or_owner",
"members:delete": "rule:admin_or_owner",
"members:get": "rule:admin_or_owner",
"members:list": "rule:admin_or_owner",
"members:update": "rule:admin_or_owner",
"services:list": "rule:admin_or_owner",
"tasks:get": "rule:admin_or_owner",

View File

@ -20,6 +20,7 @@ from mistral.policies import base
from mistral.policies import cron_trigger
from mistral.policies import environment
from mistral.policies import execution
from mistral.policies import member
def list_rules():
@ -29,5 +30,6 @@ def list_rules():
base.list_rules(),
cron_trigger.list_rules(),
environment.list_rules(),
execution.list_rules()
execution.list_rules(),
member.list_rules()
)

View File

@ -0,0 +1,83 @@
# All Rights Reserved.
#
# 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_policy import policy
from mistral.policies import base
MEMBERS = 'members:%s'
# NOTE(hieulq): all API operations of below rules are not documented in API
# reference docs yet.
rules = [
policy.DocumentedRuleDefault(
name=MEMBERS % 'create',
check_str=base.RULE_ADMIN_OR_OWNER,
description='Shares the resource to a new member.',
operations=[
{
'path': '/v2/members',
'method': 'POST'
}
]
),
policy.DocumentedRuleDefault(
name=MEMBERS % 'delete',
check_str=base.RULE_ADMIN_OR_OWNER,
description='Deletes a member from the member list of a resource.',
operations=[
{
'path': '/v2/members',
'method': 'DELETE'
}
]
),
policy.DocumentedRuleDefault(
name=MEMBERS % 'get',
check_str=base.RULE_ADMIN_OR_OWNER,
description='Shows resource member details.',
operations=[
{
'path': '/v2/members/{member_id}',
'method': 'GET'
}
]
),
policy.DocumentedRuleDefault(
name=MEMBERS % 'list',
check_str=base.RULE_ADMIN_OR_OWNER,
description='Return all members with whom the resource has been '
'shared.',
operations=[
{
'path': '/v2/members',
'method': 'GET'
}
]
),
policy.DocumentedRuleDefault(
name=MEMBERS % 'update',
check_str=base.RULE_ADMIN_OR_OWNER,
description='Sets the status for a resource member.',
operations=[
{
'path': '/v2/members',
'method': 'PUT'
}
]
)
]
def list_rules():
return rules

View File

@ -15,12 +15,6 @@
policy_data = """{
"default": "rule:admin_or_owner",
"members:create": "rule:admin_or_owner",
"members:delete": "rule:admin_or_owner",
"members:get": "rule:admin_or_owner",
"members:list": "rule:admin_or_owner",
"members:update": "rule:admin_or_owner",
"services:list": "rule:admin_or_owner",
"tasks:get": "rule:admin_or_owner",