blob: 11808368a33cbdb248cd62088cb3ae0bb1310b1a [file] [log] [blame]
DavidPurcellb25f93d2017-01-27 12:46:27 -05001# Copyright 2017 AT&T Corporation.
DavidPurcell663aedf2017-01-03 10:01:14 -05002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from oslo_config import cfg
17
18rbac_group = cfg.OptGroup(name='rbac',
19 title='RBAC testing options')
DavidPurcell029d8c32017-01-06 15:27:41 -050020
21RbacGroup = [
22 cfg.StrOpt('rbac_test_role',
23 default='admin',
24 help="The current RBAC role against which to run"
25 " Patrole tests."),
Samantha Blanco0d880082017-03-23 18:14:37 -040026 cfg.BoolOpt('enable_rbac',
Felipe Monteiro2c0c55a2017-03-06 17:22:10 -050027 default=True,
Samantha Blanco0d880082017-03-23 18:14:37 -040028 help="Enables RBAC tests."),
29 cfg.BoolOpt('strict_policy_check',
30 default=False,
31 help="If true, throws RbacParsingException for"
32 " policies which don't exist. If false, "
Samantha Blanco85f79d72017-04-21 11:09:14 -040033 "throws skipException."),
Rick Bartraed950052017-06-29 17:20:33 -040034 # TODO(rb560u): There needs to be support for reading these JSON files from
35 # other hosts. It may be possible to leverage the v3 identity policy API
Samantha Blanco85f79d72017-04-21 11:09:14 -040036 cfg.StrOpt('cinder_policy_file',
37 default='/etc/cinder/policy.json',
38 help="Location of the neutron policy file."),
39 cfg.StrOpt('glance_policy_file',
40 default='/etc/glance/policy.json',
41 help="Location of the glance policy file."),
42 cfg.StrOpt('keystone_policy_file',
43 default='/etc/keystone/policy.json',
44 help="Location of the keystone policy file."),
45 cfg.StrOpt('neutron_policy_file',
46 default='/etc/neutron/policy.json',
47 help="Location of the neutron policy file."),
48 cfg.StrOpt('nova_policy_file',
49 default='/etc/nova/policy.json',
Rick Bartraed950052017-06-29 17:20:33 -040050 help="Location of the nova policy file."),
51 cfg.BoolOpt('test_custom_requirements',
52 default=False,
53 help="""
54This option determines whether Patrole should run against a
55`custom_requirements_file` which defines RBAC requirements. The
56purpose of setting this flag to True is to verify that RBAC policy
57is in accordance to requirements. The idea is that the
58`custom_requirements_file` perfectly defines what the RBAC requirements are.
59
60Here are the possible outcomes when running the Patrole tests against
61a `custom_requirements_file`:
62
63YAML definition: allowed
64test run: allowed
65test result: pass
66
67YAML definition: allowed
68test run: not allowed
69test result: fail (under-permission)
70
71YAML definition: not allowed
72test run: allowed
73test result: fail (over-permission)
74"""),
75 cfg.StrOpt('custom_requirements_file',
76 help="""
77File path of the yaml file that defines your RBAC requirements. This
78file must be located on the same host that Patrole runs on. The yaml
79file should be written as follows:
80
81```
82<service>:
83 <api_action>:
84 - <allowed_role>
85 - <allowed_role>
86 - <allowed_role>
87 <api_action>:
88 - <allowed_role>
89 - <allowed_role>
90<service>
91 <api_action>:
92 - <allowed_role>
93```
94Where:
95service = the service that is being tested (cinder, nova, etc)
96api_action = the policy action that is being tested. Examples:
97 - volume:create
98 - os_compute_api:servers:start
99 - add_image
100allowed_role = the Keystone role that is allowed to perform the API
101""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500102]