blob: a6f30e7e8d5a1d06b12bc032635154531908c12a [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',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010024 help="""The current RBAC role against which to run Patrole
25tests."""),
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,
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010031 help="""If true, throws RbacParsingException for policies which
32don't exist or are not included in the service's policy file. If false, throws
33skipException."""),
Rick Bartraed950052017-06-29 17:20:33 -040034 # TODO(rb560u): There needs to be support for reading these JSON files from
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010035 # other hosts. It may be possible to leverage the v3 identity policy API.
36 cfg.ListOpt('custom_policy_files',
37 default=['/etc/%s/policy.json'],
38 help="""List of the paths to search for policy files. Each
39policy path assumes that the service name is included in the path once. Also
40assumes Patrole is on the same host as the policy files. The paths should be
41ordered by precedence, with high-priority paths before low-priority paths. The
42first path that is found to contain the service's policy file will be used.
43"""),
Samantha Blanco85f79d72017-04-21 11:09:14 -040044 cfg.StrOpt('cinder_policy_file',
45 default='/etc/cinder/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010046 help="""Location of the Cinder policy file. Assumed to be on
47the same host as Patrole.""",
48 deprecated_for_removal=True,
49 deprecated_reason="It is better to use `custom_policy_files` "
50 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040051 cfg.StrOpt('glance_policy_file',
52 default='/etc/glance/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010053 help="""Location of the Glance policy file. Assumed to be on
54the same host as Patrole.""",
55 deprecated_for_removal=True,
56 deprecated_reason="It is better to use `custom_policy_files` "
57 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040058 cfg.StrOpt('keystone_policy_file',
59 default='/etc/keystone/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010060 help="""Location of the custom Keystone policy file. Assumed to
61be on the same host as Patrole.""",
62 deprecated_for_removal=True,
63 deprecated_reason="It is better to use `custom_policy_files` "
64 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040065 cfg.StrOpt('neutron_policy_file',
66 default='/etc/neutron/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010067 help="""Location of the Neutron policy file. Assumed to be on
68the same host as Patrole.""",
69 deprecated_for_removal=True,
70 deprecated_reason="It is better to use `custom_policy_files` "
71 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040072 cfg.StrOpt('nova_policy_file',
73 default='/etc/nova/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010074 help="""Location of the custom Nova policy file. Assumed to be
75on the same host as Patrole.""",
76 deprecated_for_removal=True,
77 deprecated_reason="It is better to use `custom_policy_files` "
78 "which supports any OpenStack service."),
Rick Bartraed950052017-06-29 17:20:33 -040079 cfg.BoolOpt('test_custom_requirements',
80 default=False,
81 help="""
82This option determines whether Patrole should run against a
83`custom_requirements_file` which defines RBAC requirements. The
84purpose of setting this flag to True is to verify that RBAC policy
85is in accordance to requirements. The idea is that the
86`custom_requirements_file` perfectly defines what the RBAC requirements are.
87
88Here are the possible outcomes when running the Patrole tests against
89a `custom_requirements_file`:
90
91YAML definition: allowed
92test run: allowed
93test result: pass
94
95YAML definition: allowed
96test run: not allowed
97test result: fail (under-permission)
98
99YAML definition: not allowed
100test run: allowed
101test result: fail (over-permission)
102"""),
103 cfg.StrOpt('custom_requirements_file',
104 help="""
105File path of the yaml file that defines your RBAC requirements. This
106file must be located on the same host that Patrole runs on. The yaml
107file should be written as follows:
108
109```
110<service>:
111 <api_action>:
112 - <allowed_role>
113 - <allowed_role>
114 - <allowed_role>
115 <api_action>:
116 - <allowed_role>
117 - <allowed_role>
118<service>
119 <api_action>:
120 - <allowed_role>
121```
122Where:
123service = the service that is being tested (cinder, nova, etc)
124api_action = the policy action that is being tested. Examples:
125 - volume:create
126 - os_compute_api:servers:start
127 - add_image
128allowed_role = the Keystone role that is allowed to perform the API
129""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500130]