Moved CORS middleware configuration into oslo-config-generator
The default values needed for congress'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: I2edc24e4d47c4d664dd31c407d46e42fefdb1488 Closes-Bug: #1551836
This commit is contained in:
parent
2d60e988df
commit
c596b89c48
|
@ -22,6 +22,7 @@ from oslo_middleware import request_id
|
|||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from congress.common import config
|
||||
from congress.common import wsgi
|
||||
from congress import context
|
||||
|
||||
|
@ -67,6 +68,7 @@ class CongressKeystoneContext(wsgi.Middleware):
|
|||
|
||||
def pipeline_factory(loader, global_conf, **local_conf):
|
||||
"""Create a paste pipeline based on the 'auth_strategy' config option."""
|
||||
config.set_config_defaults()
|
||||
pipeline = local_conf[cfg.CONF.auth_strategy]
|
||||
pipeline = pipeline.split()
|
||||
filters = [loader.get_filter(n) for n in pipeline[:-1]]
|
||||
|
|
|
@ -21,6 +21,7 @@ import os
|
|||
from oslo_config import cfg
|
||||
from oslo_db import options as db_options
|
||||
from oslo_log import log as logging
|
||||
from oslo_middleware import cors
|
||||
from oslo_policy import opts as policy_opts
|
||||
|
||||
from congress.managers import datasource as datasource_mgr
|
||||
|
@ -106,3 +107,27 @@ def find_paste_config():
|
|||
config_path = os.path.abspath(config_path)
|
||||
LOG.info(_("Config paste file: %s"), config_path)
|
||||
return config_path
|
||||
|
||||
|
||||
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-OpenStack-Request-ID',
|
||||
'X-Identity-Status',
|
||||
'X-Roles',
|
||||
'X-Service-Catalog',
|
||||
'X-User-Id',
|
||||
'X-Tenant-Id'],
|
||||
expose_headers=['X-Auth-Token',
|
||||
'X-OpenStack-Request-ID',
|
||||
'X-Subject-Token',
|
||||
'X-Service-Token'],
|
||||
allow_methods=['GET',
|
||||
'PUT',
|
||||
'POST',
|
||||
'DELETE',
|
||||
'PATCH']
|
||||
)
|
||||
|
|
|
@ -94,6 +94,7 @@ def main():
|
|||
# event loop -> wsgi server -> webapp -> resource manager
|
||||
|
||||
paste_config = config.find_paste_config()
|
||||
config.set_config_defaults()
|
||||
servers = []
|
||||
servers.append(create_api_server(paste_config,
|
||||
"congress",
|
||||
|
|
|
@ -32,6 +32,3 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory
|
|||
[filter:cors]
|
||||
paste.filter_factory = oslo_middleware.cors:filter_factory
|
||||
oslo_config_project = congress
|
||||
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
|
||||
|
|
|
@ -32,6 +32,9 @@ setup-hooks =
|
|||
oslo.config.opts =
|
||||
congress = congress.opts:list_opts
|
||||
|
||||
oslo.config.opts.defaults =
|
||||
congress = congress.common.config:set_config_defaults
|
||||
|
||||
console_scripts =
|
||||
congress-server = congress.server.congress_server:main
|
||||
congress-db-manage = congress.db.migration.cli:main
|
||||
|
|
Loading…
Reference in New Issue