Moved CORS middleware configuration into oslo-config-generator

The default values needed for heat'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 configuration parsing. This ensures
that if a value remains unset in heat.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.

Change-Id: Ie3791007b33788829417ce508a3c719ae626bbce
Closes-Bug: 1551836
This commit is contained in:
Michael Krotscheck 2016-03-04 09:20:45 -08:00
parent e37e73e63d
commit 59ccb2f751
9 changed files with 34 additions and 3 deletions

View File

@ -59,9 +59,6 @@ heat.filter_factory = heat.api.openstack:version_negotiation_filter
[filter:cors]
paste.filter_factory = oslo_middleware.cors:filter_factory
oslo_config_project = heat
latent_allow_headers = X-Auth-Token, X-Identity-Status, X-Roles, X-Service-Catalog, X-User-Id, X-Tenant-Id, X-OpenStack-Request-ID
latent_expose_headers = X-Auth-Token, X-Subject-Token, X-Service-Token, X-OpenStack-Request-ID
latent_allow_methods = GET, PUT, POST, DELETE, PATCH
[filter:faultwrap]
paste.filter_factory = heat.common.wsgi:filter_factory

View File

@ -47,6 +47,7 @@ def main():
cfg.CONF(project='heat', prog='heat-api',
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'heat-api')
config.set_config_defaults()
messaging.setup()
app = config.load_paste_app()

View File

@ -51,6 +51,7 @@ def main():
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'heat-api-cfn')
logging.set_defaults()
config.set_config_defaults()
messaging.setup()
app = config.load_paste_app()

View File

@ -51,6 +51,7 @@ def main():
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'heat-api-cloudwatch')
logging.set_defaults()
config.set_config_defaults()
messaging.setup()
app = config.load_paste_app()

View File

@ -17,6 +17,7 @@ import os
from eventlet.green import socket
from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import cors
from osprofiler import opts as profiler
from heat.common import exception
@ -459,3 +460,27 @@ def get_client_option(client, option):
# look for the option in the generic [clients] section
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
return getattr(cfg.CONF.clients, option)
def set_config_defaults():
"""This method updates all configuration default values."""
# 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'],
expose_headers=['X-Auth-Token',
'X-Subject-Token',
'X-Service-Token',
'X-OpenStack-Request-ID'],
allow_methods=['GET',
'PUT',
'POST',
'DELETE',
'PATCH']
)

View File

@ -38,6 +38,7 @@ def init_application():
version = hversion.version_info.version_string()
cfg.CONF(project='heat', prog='heat-api', version=version)
logging.setup(cfg.CONF, 'heat-api')
config.set_config_defaults()
messaging.setup()
port = cfg.CONF.heat_api.bind_port

View File

@ -40,6 +40,7 @@ def init_application():
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'heat-api-cfn')
logging.set_defaults()
config.set_config_defaults()
messaging.setup()
port = cfg.CONF.heat_api_cfn.bind_port

View File

@ -40,6 +40,7 @@ def init_application():
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'heat-api-cloudwatch')
logging.set_defaults()
config.set_config_defaults()
messaging.setup()
port = cfg.CONF.heat_api_cloudwatch.bind_port

View File

@ -53,6 +53,9 @@ oslo.config.opts =
heat.api.aws.ec2token = heat.api.aws.ec2token:list_opts
heat_integrationtests.common.config = heat_integrationtests.common.config:list_opts
oslo.config.opts.defaults =
heat.common.config = heat.common.config:set_config_defaults
heat.clients =
barbican = heat.engine.clients.os.barbican:BarbicanClientPlugin
ceilometer = heat.engine.clients.os.ceilometer:CeilometerClientPlugin