]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Moved CORS middleware configuration into oslo-config-generator
authorMichael Krotscheck <krotscheck@gmail.com>
Tue, 1 Mar 2016 19:31:40 +0000 (11:31 -0800)
committerMichael Krotscheck <krotscheck@gmail.com>
Tue, 8 Mar 2016 16:51:52 +0000 (08:51 -0800)
The default values needed for cinder's implementation of cors
middleware have been moved from paste.ini into the configuration
hooks provided by oslo.config. Furthermore, these values have been
added to cinder's default configuration parsing. This ensures
that if a value remains unset in cinder.conf, it will be set
to use sane defaults, and that an operator modifying the
configuration file will be presented with a default set of
necessary sane headers.

Depends-on: I658e54966c390b41e3b551dd9827606c2e013511
Change-Id: Ia8735d5952d7e03b6948f748afead13e6f890271
Closes-Bug: 1551836

cinder/cmd/all.py
cinder/cmd/api.py
cinder/common/config.py
cinder/wsgi/wsgi.py
etc/cinder/api-paste.ini
setup.cfg

index 705fbff0640348f328640b9c7c1ccd036db77710..28b89758822d4c26b793e001e5c420785ef5b7a9 100644 (file)
@@ -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')
 
index 80e25eed496d9baccc85dad0b93ac930ca6ca598..aef3f58cb8c9525b96b95dcabfa287cfbad29bf6 100644 (file)
@@ -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()
index 65390fad24c5365a8fb565a4064cb7961cd34e76..24ee23d0bd7275e546d558a9c02d52f60a07ece4 100644 (file)
@@ -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']
+                     )
index 2f82905215c8e6f32d05818694e22c1f76a1739b..7b2d71d71f6d6b9ae0d1b3187fb38cea7b657a3f 100644 (file)
@@ -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')
index 5914d81af029bab1afcd6dfeb1daf27325bb3898..f4c507f9d2aad9b79c92c48b4fad1196041b2567 100644 (file)
@@ -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
index 8d8ea3123965946114a8c71a35fdf2940f6bd93a..19e340f5ff6c2d01c9b5907826c2acb2bb693323 100644 (file)
--- 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