Moved CORS middleware configuration into oslo-config-generator
The default values needed for ceilometer'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 ceilometer's default configuration parsing. This ensures that if a value remains unset in ceilometer.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. Closes-Bug: 1551836 Change-Id: Iaab90bfa1811bf6d56696648a000f02ee3306285
This commit is contained in:
parent
b79f2dd015
commit
309345268b
0
ceilometer/conf/__init__.py
Normal file
0
ceilometer/conf/__init__.py
Normal file
40
ceilometer/conf/defaults.py
Normal file
40
ceilometer/conf/defaults.py
Normal file
@ -0,0 +1,40 @@
|
||||
# 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-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']
|
||||
)
|
@ -22,6 +22,7 @@ import oslo_i18n
|
||||
from oslo_log import log
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
|
||||
from ceilometer.conf import defaults
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer import messaging
|
||||
from ceilometer import version
|
||||
@ -75,6 +76,7 @@ def prepare_service(argv=None, config_files=None):
|
||||
['stevedore=INFO', 'keystoneclient=INFO',
|
||||
'neutronclient=INFO'])
|
||||
log.set_defaults(default_log_levels=log_levels)
|
||||
defaults.set_cors_middleware_defaults()
|
||||
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
@ -22,6 +22,3 @@ paste.filter_factory = oslo_middleware:RequestId.factory
|
||||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = ceilometer
|
||||
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
|
||||
|
@ -19,6 +19,3 @@ paste.filter_factory = oslo_middleware:RequestId.factory
|
||||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = ceilometer
|
||||
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
|
@ -266,6 +266,9 @@ network.statistics.drivers =
|
||||
oslo.config.opts =
|
||||
ceilometer = ceilometer.opts:list_opts
|
||||
|
||||
oslo.config.opts.defaults =
|
||||
oslo.middleware.cors = ceilometer.conf.defaults:set_cors_middleware_defaults
|
||||
|
||||
keystoneauth1.plugin =
|
||||
password-ceilometer-legacy = ceilometer.keystone_client:LegacyCeilometerKeystoneLoader
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user