Skip to content

Commit 8615563

Browse files
committed
Global option for enforcing scope (ENFORCE_SCOPE)
This updates each devstack service library, to use it as the default value for service-specific RBAC configuration. Change-Id: I41061d042206c411ee3dd94ce91098e612af7ae7
1 parent 8339df0 commit 8615563

9 files changed

Lines changed: 19 additions & 13 deletions

File tree

.zuul.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,7 @@
646646
This job runs the devstack with scope checks enabled.
647647
vars:
648648
devstack_localrc:
649-
# Keep enabeling the services here to run with system scope
650-
CINDER_ENFORCE_SCOPE: true
651-
GLANCE_ENFORCE_SCOPE: true
652-
NEUTRON_ENFORCE_SCOPE: true
649+
ENFORCE_SCOPE: true
653650

654651
- job:
655652
name: devstack-multinode

functions-common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ function is_ironic_hardware {
11541154
}
11551155

11561156
function is_ironic_enforce_scope {
1157-
is_service_enabled ironic && [[ "$IRONIC_ENFORCE_SCOPE" == "True" ]] && return 0
1157+
is_service_enabled ironic && [[ "$IRONIC_ENFORCE_SCOPE" == "True" || "$ENFORCE_SCOPE" == "True" ]] && return 0
11581158
return 1
11591159
}
11601160

lib/cinder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function configure_cinder {
380380
iniset $CINDER_CONF coordination backend_url "etcd3+http://${SERVICE_HOST}:$ETCD_PORT"
381381
fi
382382

383-
if [[ "$CINDER_ENFORCE_SCOPE" == True ]] ; then
383+
if [[ "$CINDER_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
384384
iniset $CINDER_CONF oslo_policy enforce_scope true
385385
iniset $CINDER_CONF oslo_policy enforce_new_defaults true
386386
fi

lib/glance

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function configure_glance {
432432
iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
433433
fi
434434

435-
if [[ "$GLANCE_ENFORCE_SCOPE" == True ]] ; then
435+
if [[ "$GLANCE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
436436
iniset $GLANCE_API_CONF oslo_policy enforce_scope true
437437
iniset $GLANCE_API_CONF oslo_policy enforce_new_defaults true
438438
iniset $GLANCE_API_CONF DEFAULT enforce_secure_rbac true

lib/keystone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function configure_keystone {
265265
iniset $KEYSTONE_CONF security_compliance lockout_duration $KEYSTONE_LOCKOUT_DURATION
266266
iniset $KEYSTONE_CONF security_compliance unique_last_password_count $KEYSTONE_UNIQUE_LAST_PASSWORD_COUNT
267267
fi
268-
if [[ "$KEYSTONE_ENFORCE_SCOPE" == True ]] ; then
268+
if [[ "$KEYSTONE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
269269
iniset $KEYSTONE_CONF oslo_policy enforce_scope true
270270
iniset $KEYSTONE_CONF oslo_policy enforce_new_defaults true
271271
iniset $KEYSTONE_CONF oslo_policy policy_file policy.yaml

lib/neutron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ function configure_neutron {
632632
# configure_rbac_policies() - Configure Neutron to enforce new RBAC
633633
# policies and scopes if NEUTRON_ENFORCE_SCOPE == True
634634
function configure_rbac_policies {
635-
if [ "$NEUTRON_ENFORCE_SCOPE" == "True" ]; then
635+
if [[ "$NEUTRON_ENFORCE_SCOPE" == "True" || "ENFORCE_SCOPE" == "True" ]]; then
636636
iniset $NEUTRON_CONF oslo_policy enforce_new_defaults True
637637
iniset $NEUTRON_CONF oslo_policy enforce_scope True
638638
else

lib/neutron-legacy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ function configure_neutron_after_post_config {
500500
# configure_rbac_policies() - Configure Neutron to enforce new RBAC
501501
# policies and scopes if NEUTRON_ENFORCE_SCOPE == True
502502
function configure_rbac_policies {
503-
if [ "$NEUTRON_ENFORCE_SCOPE" == "True" ]; then
503+
if [[ "$NEUTRON_ENFORCE_SCOPE" == "True" || "$ENFORCE_SCOPE" == True ]]; then
504504
iniset $NEUTRON_CONF oslo_policy enforce_new_defaults True
505505
iniset $NEUTRON_CONF oslo_policy enforce_scope True
506506
else

lib/tempest

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,19 @@ function configure_tempest {
607607
# If services enable the enforce_scope for their policy
608608
# we need to enable the same on Tempest side so that
609609
# test can be run with scoped token.
610-
if [[ "$KEYSTONE_ENFORCE_SCOPE" == True ]] ; then
610+
if [[ "$KEYSTONE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
611611
iniset $TEMPEST_CONFIG enforce_scope keystone true
612612
iniset $TEMPEST_CONFIG auth admin_system 'all'
613613
iniset $TEMPEST_CONFIG auth admin_project_name ''
614614
fi
615-
iniset $TEMPEST_CONFIG enforce_scope glance "$GLANCE_ENFORCE_SCOPE"
616615

617-
iniset $TEMPEST_CONFIG enforce_scope cinder "$CINDER_ENFORCE_SCOPE"
616+
if [[ "$GLANCE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
617+
iniset $TEMPEST_CONFIG enforce_scope glance true
618+
fi
619+
620+
if [[ "$CINDER_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
621+
iniset $TEMPEST_CONFIG enforce_scope cinder true
622+
fi
618623

619624
if [ "$VIRT_DRIVER" = "libvirt" ] && [ "$LIBVIRT_TYPE" = "lxc" ]; then
620625
# libvirt-lxc does not support boot from volume or attaching volumes

stackrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ fi
179179
# TODO(frickler): Drop this when plugins no longer need it
180180
IDENTITY_API_VERSION=3
181181

182+
# Global option for enforcing scope. If enabled, ENFORCE_SCOPE overrides
183+
# each services ${SERVICE}_ENFORCE_SCOPE variables
184+
ENFORCE_SCOPE=$(trueorfalse False ENFORCE_SCOPE)
185+
182186
# Enable use of Python virtual environments. Individual project use of
183187
# venvs are controlled by the PROJECT_VENV array; every project with
184188
# an entry in the array will be installed into the named venv.

0 commit comments

Comments
 (0)