Skip to content

Commit ac93d8b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove deprecated enforce_secure_rbac option"
2 parents 09fce98 + b20cc91 commit ac93d8b

File tree

11 files changed

+77
-150
lines changed

11 files changed

+77
-150
lines changed

glance/api/policy.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from glance.common import exception
2727
from glance.domain import proxy
28-
from glance.i18n import _LW
2928
from glance import policies
3029

3130

@@ -64,15 +63,6 @@ def __init__(self, suppress_deprecation_warnings=False):
6463
if suppress_deprecation_warnings:
6564
self.suppress_deprecation_warnings = True
6665
self.register_defaults(policies.list_rules())
67-
if CONF.enforce_secure_rbac and CONF.oslo_policy.enforce_new_defaults:
68-
LOG.warning(_LW(
69-
"Deploying glance with secure RBAC personas enabled via "
70-
"`glance-api.conf [DEFAULT] enforce_secure_rbac=True` and "
71-
"`glance-api.conf [oslo_policy] enforce_new_defaults=True` "
72-
"is marked as EXPERIMENTAL in Wallaby. The status of this "
73-
"feature will graduate to SUPPORTED as glance adopts more "
74-
"personas, specifically for system-scope."
75-
))
7666

7767
def add_rules(self, rules):
7868
"""Add new rules to the Rules object"""

glance/api/v2/image_members.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def _check_visibility_and_ownership(self, context, image,
8282
# NOTE(abhishekk): Ownership check only needs to performed while
8383
# adding new members to image
8484
owner = image.owner
85-
if not CONF.enforce_secure_rbac and not context.is_admin:
85+
if not (CONF.oslo_policy.enforce_new_defaults or
86+
CONF.oslo_policy.enforce_scope) and not context.is_admin:
8687
if ownership_check == 'create':
8788
if owner is None or owner != context.owner:
8889
message = _("You are not permitted to create image "

glance/api/v2/policy.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ def delete_locations(self):
225225
self._enforce('delete_image_location')
226226
# TODO(danms): Remove this legacy fallback when secure RBAC
227227
# replaces the legacy policy.
228-
if not CONF.enforce_secure_rbac:
228+
if not (CONF.oslo_policy.enforce_new_defaults or
229+
CONF.oslo_policy.enforce_scope):
229230
check_is_image_mutable(self._context, self._image)
230231

231232
def get_image_location(self):
@@ -247,7 +248,8 @@ def add_image(self):
247248
raise
248249
if 'visibility' in self._target:
249250
self._enforce_visibility(self._target['visibility'])
250-
if not CONF.enforce_secure_rbac:
251+
if not (CONF.oslo_policy.enforce_new_defaults or
252+
CONF.oslo_policy.enforce_scope):
251253
check_admin_or_same_owner(self._context, self._target)
252254

253255
def get_image(self):
@@ -260,14 +262,16 @@ def delete_image(self):
260262
self._enforce('delete_image')
261263
# TODO(danms): Remove this legacy fallback when secure RBAC
262264
# replaces the legacy policy.
263-
if not CONF.enforce_secure_rbac:
265+
if not (CONF.oslo_policy.enforce_new_defaults or
266+
CONF.oslo_policy.enforce_scope):
264267
check_is_image_mutable(self._context, self._image)
265268

266269
def upload_image(self):
267270
self._enforce('upload_image')
268271
# TODO(danms): Remove this legacy fallback when secure RBAC
269272
# replaces the legacy policy.
270-
if not CONF.enforce_secure_rbac:
273+
if not (CONF.oslo_policy.enforce_new_defaults or
274+
CONF.oslo_policy.enforce_scope):
271275
check_is_image_mutable(self._context, self._image)
272276

273277
def download_image(self):
@@ -277,21 +281,24 @@ def modify_image(self):
277281
self._enforce('modify_image')
278282
# TODO(danms): Remove this legacy fallback when secure RBAC
279283
# replaces the legacy policy.
280-
if not CONF.enforce_secure_rbac:
284+
if not (CONF.oslo_policy.enforce_new_defaults or
285+
CONF.oslo_policy.enforce_scope):
281286
check_is_image_mutable(self._context, self._image)
282287

283288
def deactivate_image(self):
284289
self._enforce('deactivate')
285290
# TODO(danms): Remove this legacy fallback when secure RBAC
286291
# replaces the legacy policy.
287-
if not CONF.enforce_secure_rbac:
292+
if not (CONF.oslo_policy.enforce_new_defaults or
293+
CONF.oslo_policy.enforce_scope):
288294
check_is_image_mutable(self._context, self._image)
289295

290296
def reactivate_image(self):
291297
self._enforce('reactivate')
292298
# TODO(danms): Remove this legacy fallback when secure RBAC
293299
# replaces the legacy policy.
294-
if not CONF.enforce_secure_rbac:
300+
if not (CONF.oslo_policy.enforce_new_defaults or
301+
CONF.oslo_policy.enforce_scope):
295302
check_is_image_mutable(self._context, self._image)
296303

297304
def copy_image(self):

glance/cmd/api.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ def main():
108108
host=CONF.bind_host
109109
)
110110

111-
if CONF.enforce_secure_rbac != CONF.oslo_policy.enforce_new_defaults:
112-
fail_message = (
113-
"[DEFAULT] enforce_secure_rbac does not match "
114-
"[oslo_policy] enforce_new_defaults. Please set both to "
115-
"True to enable secure RBAC personas. Otherwise, make sure "
116-
"both are False.")
117-
raise exception.ServerError(fail_message)
118-
119111
# NOTE(danms): Configure system-wide threading model to use eventlet
120112
glance.async_.set_threadpool_model('eventlet')
121113

glance/common/config.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -593,30 +593,6 @@
593593
594594
Related options:
595595
* [DEFAULT]/node_staging_uri""")),
596-
cfg.BoolOpt('enforce_secure_rbac', default=True,
597-
deprecated_for_removal=True,
598-
deprecated_reason=_("""
599-
This option has been introduced to require operators to opt into enforcing
600-
authorization based on common RBAC personas, which is EXPERIMENTAL as of the
601-
Wallaby release. This behavior will be the default and STABLE in a future
602-
release, allowing this option to be removed.
603-
"""),
604-
deprecated_since='Wallaby',
605-
help=_("""
606-
Enforce API access based on common persona definitions used across OpenStack.
607-
Enabling this option formalizes project-specific read/write operations, like
608-
creating private images or updating the status of shared image, behind the
609-
`member` role. It also formalizes a read-only variant useful for
610-
project-specific API operations, like listing private images in a project,
611-
behind the `reader` role.
612-
613-
Operators should take an opportunity to understand glance's new image policies,
614-
audit assignments in their deployment, and update permissions using the default
615-
roles in keystone (e.g., `admin`, `member`, and `reader`).
616-
617-
Related options:
618-
* [oslo_policy]/enforce_new_defaults
619-
""")),
620596
cfg.StrOpt('worker_self_reference_url',
621597
default=None,
622598
help=_("""

glance/common/wsgi_app.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from glance.api import common
2323
import glance.async_
2424
from glance.common import config
25-
from glance.common import exception
2625
from glance.common import store_utils
2726
from glance import housekeeping
2827
from glance.i18n import _
@@ -80,16 +79,6 @@ def _setup_os_profiler():
8079
host=CONF.bind_host)
8180

8281

83-
def _validate_policy_enforcement_configuration():
84-
if CONF.enforce_secure_rbac != CONF.oslo_policy.enforce_new_defaults:
85-
fail_message = (
86-
"[DEFAULT] enforce_secure_rbac does not match "
87-
"[oslo_policy] enforce_new_defaults. Please set both to "
88-
"True to enable secure RBAC personas. Otherwise, make sure "
89-
"both are False.")
90-
raise exception.ServerError(fail_message)
91-
92-
9382
def drain_workers():
9483
# NOTE(danms): If there are any other named pools that we need to
9584
# drain before exit, they should be in this list.
@@ -155,5 +144,4 @@ def init_app():
155144
run_staging_cleanup()
156145

157146
_setup_os_profiler()
158-
_validate_policy_enforcement_configuration()
159147
return config.load_paste_app('glance-api')

glance/tests/functional/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ def __init__(self, test_dir, port, policy_file, delayed_delete=False,
408408
self.image_location_quota = 2
409409
self.disable_path = None
410410

411-
secure_rbac = bool(os.getenv('OS_GLANCE_TEST_RBAC_DEFAULTS'))
412-
self.enforce_secure_rbac = secure_rbac
413-
self.enforce_new_defaults = secure_rbac
411+
self.enforce_new_defaults = True
414412

415413
self.needs_database = True
416414
default_sql_connection = SQLITE_CONN_TEMPLATE % self.test_dir
@@ -456,7 +454,6 @@ def __init__(self, test_dir, port, policy_file, delayed_delete=False,
456454
location_strategy=%(location_strategy)s
457455
allow_additional_image_properties = True
458456
node_staging_uri=%(node_staging_uri)s
459-
enforce_secure_rbac=%(enforce_secure_rbac)s
460457
[oslo_policy]
461458
policy_file = %(policy_file)s
462459
policy_default_rule = %(policy_default_rule)s
@@ -585,7 +582,6 @@ def __init__(self, test_dir, port, policy_file, delayed_delete=False,
585582
self.image_location_quota = 2
586583
self.disable_path = None
587584

588-
self.enforce_secure_rbac = True
589585
self.enforce_new_defaults = True
590586

591587
self.needs_database = True
@@ -629,7 +625,6 @@ def __init__(self, test_dir, port, policy_file, delayed_delete=False,
629625
location_strategy=%(location_strategy)s
630626
allow_additional_image_properties = True
631627
enabled_backends=file1:file,file2:file,file3:file
632-
enforce_secure_rbac=%(enforce_secure_rbac)s
633628
[oslo_policy]
634629
policy_file = %(policy_file)s
635630
policy_default_rule = %(policy_default_rule)s
@@ -1620,9 +1615,9 @@ def start_server(self, enable_cache=True):
16201615

16211616
self.api = config.load_paste_app(root_app,
16221617
conf_file=self.paste_config)
1623-
secure_rbac = bool(os.getenv('OS_GLANCE_TEST_RBAC_DEFAULTS'))
1624-
self.config(enforce_secure_rbac=secure_rbac)
1625-
self.config(enforce_new_defaults=secure_rbac,
1618+
self.config(enforce_new_defaults=True,
1619+
group='oslo_policy')
1620+
self.config(enforce_scope=True,
16261621
group='oslo_policy')
16271622

16281623
def _headers(self, custom_headers=None):

glance/tests/unit/common/test_wsgi_app.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from glance.api import common
2020
from glance.api.v2 import cached_images
2121
import glance.async_
22-
from glance.common import exception
2322
from glance.common import wsgi_app
2423
from glance.tests import utils as test_utils
2524

@@ -91,40 +90,6 @@ def test_drain_workers_no_cache(self):
9190
wsgi_app.drain_workers()
9291
self.assertIsNone(cached_images.WORKER)
9392

94-
@mock.patch('glance.common.config.load_paste_app')
95-
@mock.patch('glance.async_.set_threadpool_model')
96-
@mock.patch('glance.common.wsgi_app._get_config_files')
97-
def test_policy_enforcement_kills_service_if_misconfigured(
98-
self, mock_load_app, mock_set, mock_config_files):
99-
self.config(enforce_new_defaults=True, group='oslo_policy')
100-
self.config(enforce_secure_rbac=False)
101-
self.assertRaises(exception.ServerError, wsgi_app.init_app)
102-
103-
self.config(enforce_new_defaults=False, group='oslo_policy')
104-
self.config(enforce_secure_rbac=True)
105-
self.assertRaises(exception.ServerError, wsgi_app.init_app)
106-
107-
@mock.patch('glance.common.config.load_paste_app')
108-
@mock.patch('glance.async_.set_threadpool_model')
109-
@mock.patch('glance.common.wsgi_app._get_config_files')
110-
def test_policy_enforcement_valid_truthy_configuration(
111-
self, mock_load_app, mock_set, mock_config_files):
112-
self.config(enforce_new_defaults=True, group='oslo_policy')
113-
self.config(enforce_secure_rbac=True)
114-
self.assertTrue(wsgi_app.init_app())
115-
116-
@mock.patch('glance.common.config.load_paste_app')
117-
@mock.patch('glance.async_.set_threadpool_model')
118-
@mock.patch('glance.common.wsgi_app._get_config_files')
119-
def test_policy_enforcement_valid_falsy_configuration(
120-
self, mock_load_app, mock_set, mock_config_files):
121-
# This is effectively testing the default values, but we're doing that
122-
# to make sure nothing bad happens at runtime in the default case when
123-
# validating policy enforcement configuration.
124-
self.config(enforce_new_defaults=False, group='oslo_policy')
125-
self.config(enforce_secure_rbac=False)
126-
self.assertTrue(wsgi_app.init_app())
127-
12893
@mock.patch('glance.async_._THREADPOOL_MODEL', new=None)
12994
@mock.patch('glance.common.config.load_paste_app')
13095
@mock.patch('glance.common.wsgi_app._get_config_files')

glance/tests/unit/test_policy.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -394,29 +394,6 @@ def test_ensure_context_object_is_passed_to_policy_enforcement(self):
394394
enforcer.check(context, 'foo', {})
395395
mock_enforcer.assert_called_once_with('foo', {}, context)
396396

397-
def test_ensure_experimental_warning_is_logged_for_secure_rbac(self):
398-
self.config(enforce_new_defaults=True, group='oslo_policy')
399-
self.config(enforce_secure_rbac=True)
400-
expected_log_string = (
401-
"Deploying glance with secure RBAC personas enabled via "
402-
"`glance-api.conf [DEFAULT] enforce_secure_rbac=True` and "
403-
"`glance-api.conf [oslo_policy] enforce_new_defaults=True` "
404-
"is marked as EXPERIMENTAL in Wallaby. The status of this "
405-
"feature will graduate to SUPPORTED as glance adopts more "
406-
"personas, specifically for system-scope."
407-
)
408-
with mock.patch.object(glance.api.policy, 'LOG') as mock_log:
409-
glance.api.policy.Enforcer(
410-
suppress_deprecation_warnings=True)
411-
mock_log.warning.assert_called_once_with(expected_log_string)
412-
413-
def test_ensure_experimental_warning_is_not_logged_for_legacy_rbac(self):
414-
self.config(enforce_new_defaults=False, group='oslo_policy')
415-
with mock.patch.object(glance.api.policy, 'LOG') as mock_log:
416-
glance.api.policy.Enforcer(
417-
suppress_deprecation_warnings=True)
418-
mock_log.warning.assert_not_called()
419-
420397

421398
class TestPolicyEnforcerNoFile(base.IsolatedUnitTest):
422399

0 commit comments

Comments
 (0)