Moved CORS middleware configuration into oslo-config-generator
The default values needed for solum'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 solum.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: I6f30224ac1b11fc4019dbc5ae5ec1e1fedbfe97d Closes-Bug: 1551836
This commit is contained in:
parent
6ee1345a9e
commit
dbfdf9f5db
|
@ -81,5 +81,8 @@ oslo.config.opts =
|
|||
solum.deployer.handlers.heat = solum.deployer.handlers.heat:list_opts
|
||||
solum.worker.config = solum.worker.config:list_opts
|
||||
|
||||
oslo.config.opts.defaults =
|
||||
oslo.middleware.cors = solum.common.config:set_cors_middleware_defaults
|
||||
|
||||
[wheel]
|
||||
universal = 1
|
||||
|
|
|
@ -81,12 +81,5 @@ def setup_app(config=None):
|
|||
# Create a CORS wrapper, and attach solum-specific defaults that must be
|
||||
# supported on all CORS responses.
|
||||
app = cors_middleware.CORS(app, CONF)
|
||||
app.set_latent(
|
||||
allow_headers=['X-Auth-Token', 'X-Openstack-Request-Id',
|
||||
'X-Subject-Token'],
|
||||
allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
|
||||
expose_headers=['X-Auth-Token', 'X-Openstack-Request-Id',
|
||||
'X-Subject-Token']
|
||||
)
|
||||
|
||||
return app
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Copyright (c) 2016 Hewlett Packard Enterprise Development Corporation, LP
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_middleware import cors
|
||||
|
||||
|
||||
def set_config_defaults():
|
||||
"""This method updates all configuration default values."""
|
||||
set_cors_middleware_defaults()
|
||||
|
||||
|
||||
def set_cors_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-Subject-Token'],
|
||||
expose_headers=['X-Auth-Token',
|
||||
'X-Openstack-Request-Id',
|
||||
'X-Subject-Token'],
|
||||
allow_methods=['GET',
|
||||
'PUT',
|
||||
'POST',
|
||||
'DELETE',
|
||||
'PATCH']
|
||||
)
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from solum.common import config
|
||||
from solum import objects
|
||||
from solum.openstack.common import log as logging
|
||||
|
||||
|
@ -21,4 +22,5 @@ from solum.openstack.common import log as logging
|
|||
def prepare_service(argv=[]):
|
||||
cfg.CONF(argv[1:], project='solum')
|
||||
logging.setup('solum')
|
||||
config.set_config_defaults()
|
||||
objects.load()
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from solum.common import config
|
||||
from solum import version
|
||||
|
||||
|
||||
|
@ -24,3 +25,4 @@ def parse_args(argv, default_config_files=None):
|
|||
project='solum',
|
||||
version=version.version_string(),
|
||||
default_config_files=default_config_files)
|
||||
config.set_config_defaults()
|
||||
|
|
Loading…
Reference in New Issue