diff --git a/cinder/cmd/all.py b/cinder/cmd/all.py index 705fbff0640..28b89758822 100644 --- a/cinder/cmd/all.py +++ b/cinder/cmd/all.py @@ -59,6 +59,7 @@ def main(): gmr_opts.set_defaults(CONF) CONF(sys.argv[1:], project='cinder', version=version.version_string()) + config.set_middleware_defaults() logging.setup(CONF, "cinder") LOG = logging.getLogger('cinder.all') diff --git a/cinder/cmd/api.py b/cinder/cmd/api.py index 80e25eed496..aef3f58cb8c 100644 --- a/cinder/cmd/api.py +++ b/cinder/cmd/api.py @@ -34,7 +34,7 @@ from cinder import i18n i18n.enable_lazy() # Need to register global_opts -from cinder.common import config # noqa +from cinder.common import config from cinder import rpc from cinder import service from cinder import utils @@ -49,6 +49,7 @@ def main(): gmr_opts.set_defaults(CONF) CONF(sys.argv[1:], project='cinder', version=version.version_string()) + config.set_middleware_defaults() logging.setup(CONF, "cinder") python_logging.captureWarnings(True) utils.monkey_patch() diff --git a/cinder/common/config.py b/cinder/common/config.py index 65390fad24c..24ee23d0bd7 100644 --- a/cinder/common/config.py +++ b/cinder/common/config.py @@ -29,6 +29,7 @@ import socket from oslo_config import cfg from oslo_log import log as logging +from oslo_middleware import cors from oslo_utils import netutils from cinder.i18n import _ @@ -209,3 +210,32 @@ global_opts = [ ] CONF.register_opts(global_opts) + + +def set_middleware_defaults(): + """Update default configuration options for oslo.middleware.""" + # CORS Defaults + # TODO(krotscheck): Update with https://review.openstack.org/#/c/285368/ + cfg.set_defaults(cors.CORS_OPTS, + allow_headers=['X-Auth-Token', + 'X-Identity-Status', + 'X-Roles', + 'X-Service-Catalog', + 'X-User-Id', + 'X-Tenant-Id', + 'X-OpenStack-Request-ID', + 'X-Trace-Info', + 'X-Trace-HMAC', + 'OpenStack-API-Version'], + expose_headers=['X-Auth-Token', + 'X-Subject-Token', + 'X-Service-Token', + 'X-OpenStack-Request-ID', + 'OpenStack-API-Version'], + allow_methods=['GET', + 'PUT', + 'POST', + 'DELETE', + 'PATCH', + 'HEAD'] + ) diff --git a/cinder/wsgi/wsgi.py b/cinder/wsgi/wsgi.py index 2f82905215c..7b2d71d71f6 100644 --- a/cinder/wsgi/wsgi.py +++ b/cinder/wsgi/wsgi.py @@ -28,7 +28,7 @@ from cinder import i18n i18n.enable_lazy() # Need to register global_opts -from cinder.common import config # noqa +from cinder.common import config from cinder import rpc from cinder import version @@ -40,6 +40,7 @@ def initialize_application(): CONF(sys.argv[1:], project='cinder', version=version.version_string()) logging.setup(CONF, "cinder") + config.set_middleware_defaults() rpc.init(CONF) return wsgi.Loader(CONF).load_app(name='osapi_volume') diff --git a/etc/cinder/api-paste.ini b/etc/cinder/api-paste.ini index 5914d81af02..f4c507f9d2a 100644 --- a/etc/cinder/api-paste.ini +++ b/etc/cinder/api-paste.ini @@ -33,9 +33,6 @@ paste.filter_factory = oslo_middleware.request_id:RequestId.factory [filter:cors] paste.filter_factory = oslo_middleware.cors:filter_factory oslo_config_project = cinder -latent_allow_headers = X-Auth-Token, X-Identity-Status, X-Roles, X-Service-Catalog, X-User-Id, X-Tenant-Id, X-OpenStack-Request-ID, X-Trace-Info, X-Trace-HMAC, OpenStack-Volume-microversion -latent_expose_headers = X-Auth-Token, X-Subject-Token, X-Service-Token, X-OpenStack-Request-ID, OpenStack-Volume-microversion -latent_allow_methods = GET, PUT, POST, DELETE, PATCH [filter:faultwrap] paste.filter_factory = cinder.api.middleware.fault:FaultWrapper.factory diff --git a/setup.cfg b/setup.cfg index 8d8ea312396..19e340f5ff6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,6 +47,8 @@ oslo.config.opts = oslo_concurrency = oslo_concurrency.opts:list_opts oslo.messaging = oslo_messaging.opts:list_opts oslo.db.concurrency = oslo.db.concurrency:list_opts +oslo.config.opts.defaults = + oslo.middleware = cinder.common.config:set_middleware_defaults console_scripts = cinder-all = cinder.cmd.all:main cinder-api = cinder.cmd.api:main