Moved CORS middleware configuration into oslo-config-generator
The default values needed for aodh'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 aodh's default configuration parsing. This ensures that if a value remains unset in aodh.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: Iccdbbfcc300f4a63fe7a58f0742eef782aff6844 Closes-Bug: 1551836
This commit is contained in:
parent
27fb5f735c
commit
7e638e07ed
0
aodh/conf/__init__.py
Normal file
0
aodh/conf/__init__.py
Normal file
35
aodh/conf/defaults.py
Normal file
35
aodh/conf/defaults.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||
#
|
||||
# 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_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']
|
||||
)
|
@ -22,6 +22,7 @@ import oslo_i18n
|
||||
from oslo_log import log
|
||||
from oslo_policy import opts as policy_opts
|
||||
|
||||
from aodh.conf import defaults
|
||||
from aodh import keystone_client
|
||||
from aodh import messaging
|
||||
|
||||
@ -54,6 +55,7 @@ def prepare_service(argv=None, config_files=None):
|
||||
log_levels = (conf.default_log_levels +
|
||||
['stevedore=INFO', 'keystoneclient=INFO'])
|
||||
log.set_defaults(default_log_levels=log_levels)
|
||||
defaults.set_cors_middleware_defaults()
|
||||
db_options.set_defaults(conf)
|
||||
policy_opts.set_defaults(conf)
|
||||
from aodh import opts
|
||||
|
@ -19,6 +19,3 @@ paste.filter_factory = oslo_middleware:RequestId.factory
|
||||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = aodh
|
||||
latent_allow_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token
|
||||
latent_expose_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token
|
||||
latent_allow_methods = GET, PUT, POST, DELETE, PATCH
|
||||
|
@ -19,7 +19,4 @@ paste.filter_factory = oslo_middleware:RequestId.factory
|
||||
|
||||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = aodh
|
||||
latent_allow_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token
|
||||
latent_expose_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token
|
||||
latent_allow_methods = GET, PUT, POST, DELETE, PATCH
|
||||
oslo_config_project = aodh
|
@ -114,6 +114,9 @@ oslo.config.opts =
|
||||
aodh = aodh.opts:list_opts
|
||||
aodh-auth = aodh.opts:list_keystoneauth_opts
|
||||
|
||||
oslo.config.opts.defaults =
|
||||
oslo.middleware.cors = aodh.conf.defaults:set_cors_middleware_defaults
|
||||
|
||||
keystoneauth1.plugin =
|
||||
password-aodh-legacy = aodh.keystone_client:LegacyAodhKeystoneLoader
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user