Moved CORS middleware configuration into oslo-config-generator
The default values needed for magnum'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: I7d8f8708d53bbab117600070982ac80482fa0a77 Closes-Bug: 1551836
This commit is contained in:
parent
9bd983c3a7
commit
a5883fd3af
|
@ -14,6 +14,3 @@ paste.filter_factory = oslo_middleware:RequestId.factory
|
|||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = magnum
|
||||
latent_allow_methods = GET, PUT, POST, DELETE, PATCH
|
||||
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
|
||||
|
|
|
@ -18,6 +18,7 @@ import pecan
|
|||
|
||||
from magnum.api import config as api_config
|
||||
from magnum.api import middleware
|
||||
from magnum.common import config as common_config
|
||||
from magnum.i18n import _
|
||||
|
||||
# Register options for the service
|
||||
|
@ -58,6 +59,7 @@ def setup_app(config=None):
|
|||
config = get_pecan_config()
|
||||
|
||||
app_conf = dict(config.app)
|
||||
common_config.set_config_defaults()
|
||||
|
||||
app = pecan.make_app(
|
||||
app_conf.pop('root'),
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_middleware import cors
|
||||
|
||||
from magnum.common import rpc
|
||||
from magnum import version
|
||||
|
@ -28,3 +29,34 @@ def parse_args(argv, default_config_files=None):
|
|||
version=version.version_info.release_string(),
|
||||
default_config_files=default_config_files)
|
||||
rpc.init(cfg.CONF)
|
||||
|
||||
|
||||
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-Identity-Status',
|
||||
'X-Roles',
|
||||
'X-Service-Catalog',
|
||||
'X-User-Id',
|
||||
'X-Tenant-Id',
|
||||
'X-OpenStack-Request-ID',
|
||||
'X-Server-Management-Url'],
|
||||
expose_headers=['X-Auth-Token',
|
||||
'X-Subject-Token',
|
||||
'X-Service-Token',
|
||||
'X-OpenStack-Request-ID',
|
||||
'X-Server-Management-Url'],
|
||||
allow_methods=['GET',
|
||||
'PUT',
|
||||
'POST',
|
||||
'DELETE',
|
||||
'PATCH']
|
||||
)
|
||||
|
|
|
@ -39,4 +39,6 @@ def prepare_service(argv=None):
|
|||
argv = []
|
||||
logging.register_options(cfg.CONF)
|
||||
config.parse_args(argv)
|
||||
config.set_config_defaults()
|
||||
|
||||
logging.setup(cfg.CONF, 'magnum')
|
||||
|
|
|
@ -52,6 +52,9 @@ console_scripts =
|
|||
oslo.config.opts =
|
||||
magnum = magnum.opts:list_opts
|
||||
|
||||
oslo.config.opts.defaults =
|
||||
oslo.middleware.cors = magnum.common.config:set_cors_middleware_defaults
|
||||
|
||||
magnum.template_definitions =
|
||||
magnum_vm_atomic_k8s = magnum.conductor.template_definition:AtomicK8sTemplateDefinition
|
||||
magnum_vm_coreos_k8s = magnum.conductor.template_definition:CoreOSK8sTemplateDefinition
|
||||
|
|
Loading…
Reference in New Issue