DavidPurcell | b25f93d | 2017-01-27 12:46:27 -0500 | [diff] [blame] | 1 | # Copyright 2017 AT&T Corporation. |
DavidPurcell | 663aedf | 2017-01-03 10:01:14 -0500 | [diff] [blame] | 2 | # 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 | |
| 16 | from oslo_config import cfg |
| 17 | |
| 18 | rbac_group = cfg.OptGroup(name='rbac', |
| 19 | title='RBAC testing options') |
DavidPurcell | 029d8c3 | 2017-01-06 15:27:41 -0500 | [diff] [blame] | 20 | |
| 21 | RbacGroup = [ |
| 22 | cfg.StrOpt('rbac_test_role', |
| 23 | default='admin', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 24 | help="""The current RBAC role against which to run Patrole |
| 25 | tests."""), |
Samantha Blanco | 0d88008 | 2017-03-23 18:14:37 -0400 | [diff] [blame] | 26 | cfg.BoolOpt('enable_rbac', |
Felipe Monteiro | 2c0c55a | 2017-03-06 17:22:10 -0500 | [diff] [blame] | 27 | default=True, |
Samantha Blanco | 0d88008 | 2017-03-23 18:14:37 -0400 | [diff] [blame] | 28 | help="Enables RBAC tests."), |
| 29 | cfg.BoolOpt('strict_policy_check', |
| 30 | default=False, |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 31 | help="""If true, throws RbacParsingException for policies which |
| 32 | don't exist or are not included in the service's policy file. If false, throws |
| 33 | skipException."""), |
Rick Bartra | ed95005 | 2017-06-29 17:20:33 -0400 | [diff] [blame] | 34 | # TODO(rb560u): There needs to be support for reading these JSON files from |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 35 | # 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 |
| 39 | policy path assumes that the service name is included in the path once. Also |
| 40 | assumes Patrole is on the same host as the policy files. The paths should be |
| 41 | ordered by precedence, with high-priority paths before low-priority paths. The |
| 42 | first path that is found to contain the service's policy file will be used. |
| 43 | """), |
Samantha Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 44 | cfg.StrOpt('cinder_policy_file', |
| 45 | default='/etc/cinder/policy.json', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 46 | help="""Location of the Cinder policy file. Assumed to be on |
| 47 | the 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 Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 51 | cfg.StrOpt('glance_policy_file', |
| 52 | default='/etc/glance/policy.json', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 53 | help="""Location of the Glance policy file. Assumed to be on |
| 54 | the 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 Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 58 | cfg.StrOpt('keystone_policy_file', |
| 59 | default='/etc/keystone/policy.json', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 60 | help="""Location of the custom Keystone policy file. Assumed to |
| 61 | be 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 Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 65 | cfg.StrOpt('neutron_policy_file', |
| 66 | default='/etc/neutron/policy.json', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 67 | help="""Location of the Neutron policy file. Assumed to be on |
| 68 | the 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 Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 72 | cfg.StrOpt('nova_policy_file', |
| 73 | default='/etc/nova/policy.json', |
Felipe Monteiro | 3ab2c35 | 2017-07-05 22:25:34 +0100 | [diff] [blame] | 74 | help="""Location of the custom Nova policy file. Assumed to be |
| 75 | on 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 Bartra | ed95005 | 2017-06-29 17:20:33 -0400 | [diff] [blame] | 79 | cfg.BoolOpt('test_custom_requirements', |
| 80 | default=False, |
| 81 | help=""" |
| 82 | This option determines whether Patrole should run against a |
| 83 | `custom_requirements_file` which defines RBAC requirements. The |
| 84 | purpose of setting this flag to True is to verify that RBAC policy |
| 85 | is in accordance to requirements. The idea is that the |
| 86 | `custom_requirements_file` perfectly defines what the RBAC requirements are. |
| 87 | |
| 88 | Here are the possible outcomes when running the Patrole tests against |
| 89 | a `custom_requirements_file`: |
| 90 | |
| 91 | YAML definition: allowed |
| 92 | test run: allowed |
| 93 | test result: pass |
| 94 | |
| 95 | YAML definition: allowed |
| 96 | test run: not allowed |
| 97 | test result: fail (under-permission) |
| 98 | |
| 99 | YAML definition: not allowed |
| 100 | test run: allowed |
| 101 | test result: fail (over-permission) |
| 102 | """), |
| 103 | cfg.StrOpt('custom_requirements_file', |
| 104 | help=""" |
| 105 | File path of the yaml file that defines your RBAC requirements. This |
| 106 | file must be located on the same host that Patrole runs on. The yaml |
| 107 | file 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 | ``` |
| 122 | Where: |
| 123 | service = the service that is being tested (cinder, nova, etc) |
| 124 | api_action = the policy action that is being tested. Examples: |
| 125 | - volume:create |
| 126 | - os_compute_api:servers:start |
| 127 | - add_image |
| 128 | allowed_role = the Keystone role that is allowed to perform the API |
| 129 | """) |
DavidPurcell | 029d8c3 | 2017-01-06 15:27:41 -0500 | [diff] [blame] | 130 | ] |