Moved CORS middleware configuration into oslo-config-generator

The default values needed for murano'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 the default initialization procedure. This ensures
that if a value remains unset in the configuration file, it will
fallback to using sane defaults. It also ensures that an operator
modifying the configuration will be presented with that same
set of defaults.

Change-Id: I50a204e27a43991d94cfb5f39c1dd3e904eb5696
Closes-Bug: #1551836
This commit is contained in:
Tin Lam
2016-03-02 19:30:10 -06:00
parent e3f342a378
commit 151d8cfe30
5 changed files with 31 additions and 3 deletions

View File

@@ -45,6 +45,3 @@ paste.filter_factory = murano.api.middleware.ext_context:ExternalContextMiddlewa
[filter:cors]
paste.filter_factory = oslo_middleware.cors:filter_factory
oslo_config_project = murano
latent_allow_headers = X-Auth-Token, X-Openstack-Request-Id, X-Configuration-Session, X-Roles, X-User-Id, X-Tenant-Id
latent_expose_headers = X-Auth-Token, X-Openstack-Request-Id, X-Configuration-Session, X-Roles, X-User-Id, X-Tenant-Id
latent_allow_methods = GET, PUT, POST, DELETE, PATCH

1
murano/cmd/api.py Normal file → Executable file
View File

@@ -54,6 +54,7 @@ if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
def main():
try:
config.parse_args()
config.set_middleware_defaults()
request_statistics.init_stats()
policy.init()

View File

@@ -15,6 +15,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import cors
from murano.common.i18n import _
from murano import version
@@ -303,3 +304,28 @@ def parse_args(args=None, usage=None, default_config_files=None):
version=version.version_string,
usage=usage,
default_config_files=default_config_files)
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-Openstack-Request-Id',
'X-Configuration-Session',
'X-Roles',
'X-User-Id',
'X-Tenant-Id'],
expose_headers=['X-Auth-Token',
'X-Openstack-Request-Id',
'X-Configuration-Session',
'X-Roles',
'X-User-Id',
'X-Tenant-Id'],
allow_methods=['GET',
'PUT',
'POST',
'DELETE',
'PATCH']
)

View File

@@ -39,6 +39,7 @@ import webob.dec
import webob.exc
from murano.api.v1 import schemas
from murano.common import config
from murano.common import exceptions
from murano.common.i18n import _, _LE, _LW
from murano.common import xmlutils
@@ -82,6 +83,7 @@ class Service(service.Service):
self._backlog = backlog if backlog else CONF.backlog
self._logger = logging.getLogger('eventlet.wsgi')
self.greenthread = None
config.set_middleware_defaults()
super(Service, self).__init__(threads)
def _get_socket(self, host, port, backlog):

View File

@@ -50,6 +50,8 @@ console_scripts =
oslo.config.opts =
murano = murano.opts:list_opts
keystone_authtoken = keystonemiddleware.opts:list_auth_token_opts
oslo.config.opts.defaults =
oslo.middleware = murano.common.config:set_middleware_defaults
tempest.test_plugins =
murano_tests = murano_tempest_tests.plugin:MuranoTempestPlugin