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', |
| 24 | help="The current RBAC role against which to run" |
| 25 | " Patrole 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, |
| 31 | help="If true, throws RbacParsingException for" |
| 32 | " policies which don't exist. If false, " |
Samantha Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 33 | "throws 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 |
| 35 | # other hosts. It may be possible to leverage the v3 identity policy API |
Samantha Blanco | 85f79d7 | 2017-04-21 11:09:14 -0400 | [diff] [blame] | 36 | 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 Bartra | ed95005 | 2017-06-29 17:20:33 -0400 | [diff] [blame^] | 50 | help="Location of the nova policy file."), |
| 51 | cfg.BoolOpt('test_custom_requirements', |
| 52 | default=False, |
| 53 | help=""" |
| 54 | This option determines whether Patrole should run against a |
| 55 | `custom_requirements_file` which defines RBAC requirements. The |
| 56 | purpose of setting this flag to True is to verify that RBAC policy |
| 57 | is in accordance to requirements. The idea is that the |
| 58 | `custom_requirements_file` perfectly defines what the RBAC requirements are. |
| 59 | |
| 60 | Here are the possible outcomes when running the Patrole tests against |
| 61 | a `custom_requirements_file`: |
| 62 | |
| 63 | YAML definition: allowed |
| 64 | test run: allowed |
| 65 | test result: pass |
| 66 | |
| 67 | YAML definition: allowed |
| 68 | test run: not allowed |
| 69 | test result: fail (under-permission) |
| 70 | |
| 71 | YAML definition: not allowed |
| 72 | test run: allowed |
| 73 | test result: fail (over-permission) |
| 74 | """), |
| 75 | cfg.StrOpt('custom_requirements_file', |
| 76 | help=""" |
| 77 | File path of the yaml file that defines your RBAC requirements. This |
| 78 | file must be located on the same host that Patrole runs on. The yaml |
| 79 | file 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 | ``` |
| 94 | Where: |
| 95 | service = the service that is being tested (cinder, nova, etc) |
| 96 | api_action = the policy action that is being tested. Examples: |
| 97 | - volume:create |
| 98 | - os_compute_api:servers:start |
| 99 | - add_image |
| 100 | allowed_role = the Keystone role that is allowed to perform the API |
| 101 | """) |
DavidPurcell | 029d8c3 | 2017-01-06 15:27:41 -0500 | [diff] [blame] | 102 | ] |