Added CORS support to Senlin

OpenStack CrossProject Spec:
   http://specs.openstack.org/openstack/openstack-specs/specs/cors-support.html
Oslo_Middleware Docs:
   http://docs.openstack.org/developer/oslo.middleware/cors.html
OpenStack Cloud Admin Guide:
   http://docs.openstack.org/admin-guide-cloud/cross_project_cors.html

Change-Id: Iedd14f7aebf0969e79b74ec3400e4362029d1b63
This commit is contained in:
Aaron-DH 2017-03-08 16:58:30 +08:00
parent e08f57ef0c
commit e900491c79
6 changed files with 35 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# senlin-api pipeline
[pipeline:senlin-api]
pipeline = http_proxy_to_wsgi request_id faultwrap ssl versionnegotiation osprofiler webhook authtoken context trust apiv1app
pipeline = cors http_proxy_to_wsgi request_id faultwrap ssl versionnegotiation osprofiler webhook authtoken context trust apiv1app
[app:apiv1app]
paste.app_factory = senlin.api.common.wsgi:app_factory
@ -44,3 +44,7 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory
[filter:osprofiler]
paste.filter_factory = osprofiler.web:WsgiMiddleware.factory
[filter:cors]
paste.filter_factory = oslo_middleware.cors:filter_factory
oslo_config_project = senlin

View File

@ -24,6 +24,7 @@ from oslo_service import systemd
import six
from senlin.api.common import wsgi
from senlin.common import config
from senlin.common.i18n import _LI
from senlin.common import messaging
from senlin.common import profiler
@ -40,6 +41,7 @@ def main():
logging.register_options(cfg.CONF)
cfg.CONF(project='senlin', prog='senlin-api',
version=version.version_info.version_string())
config.set_config_defaults()
logging.setup(cfg.CONF, 'senlin-api')
objects.register_all()
messaging.setup()

View File

@ -23,6 +23,7 @@ import oslo_i18n as i18n
from oslo_log import log as logging
from senlin.api.common import wsgi
from senlin.common import config
from senlin.common import messaging
from senlin.common import profiler
from senlin import version
@ -35,6 +36,7 @@ def init_app():
cfg.CONF(project='senlin', prog='senlin-api',
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'senlin-api')
config.set_config_defaults()
messaging.setup()
profiler.setup('senlin-api', cfg.CONF.host)

View File

@ -17,6 +17,7 @@ import socket
from keystoneauth1 import loading as ks_loading
from oslo_config import cfg
from oslo_middleware import cors
from osprofiler import opts as profiler
from senlin.api.common import wsgi
@ -233,3 +234,24 @@ def list_opts():
yield receiver_group.name, receiver_opts
yield zaqar_group.name, zaqar_opts
yield profiler.list_opts()[0]
def set_config_defaults():
"""Update default configuration options for oslo.middleware."""
cors.set_defaults(
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'])

View File

@ -35,6 +35,9 @@ wsgi_scripts =
oslo.config.opts =
senlin.config = senlin.common.config:list_opts
oslo.config.opts.defaults =
senlin.config = senlin.common.config:set_config_defaults
senlin.drivers =
openstack = senlin.drivers.openstack
openstack_test = senlin.tests.drivers.openstack

View File

@ -6,6 +6,7 @@ namespace = keystonemiddleware.auth_token
namespace = oslo.db
namespace = oslo.log
namespace = oslo.messaging
namespace = oslo.middleware.cors
namespace = oslo.middleware.http_proxy_to_wsgi
namespace = oslo.policy
namespace = oslo.service.periodic_task