summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/ironic/ironic.conf.sample62
-rw-r--r--ironic/api/app.py11
-rw-r--r--requirements.txt1
-rw-r--r--tools/config/oslo.config.generator.rc2
-rw-r--r--vagrant.yaml13
5 files changed, 87 insertions, 2 deletions
diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample
index d50dfcf98..a60675de7 100644
--- a/etc/ironic/ironic.conf.sample
+++ b/etc/ironic/ironic.conf.sample
@@ -598,6 +598,68 @@
#subprocess_timeout=10
+[cors]
+
+#
+# Options defined in oslo.middleware.cors
+#
+
+# Indicate whether this resource may be shared with the domain
+# received in the requests "origin" header. (string value)
+#allowed_origin=<None>
+
+# Indicate that the actual request can include user
+# credentials (boolean value)
+#allow_credentials=true
+
+# Indicate which headers are safe to expose to the API.
+# Defaults to HTTP Simple Headers. (list value)
+#expose_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma
+
+# Maximum cache age of CORS preflight requests. (integer
+# value)
+#max_age=3600
+
+# Indicate which methods can be used during the actual
+# request. (list value)
+#allow_methods=GET,POST,PUT,DELETE,OPTIONS
+
+# Indicate which header field names may be used during the
+# actual request. (list value)
+#allow_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma
+
+
+[cors.subdomain]
+
+#
+# Options defined in oslo.middleware.cors
+#
+
+# Indicate whether this resource may be shared with the domain
+# received in the requests "origin" header. (string value)
+#allowed_origin=<None>
+
+# Indicate that the actual request can include user
+# credentials (boolean value)
+#allow_credentials=true
+
+# Indicate which headers are safe to expose to the API.
+# Defaults to HTTP Simple Headers. (list value)
+#expose_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma
+
+# Maximum cache age of CORS preflight requests. (integer
+# value)
+#max_age=3600
+
+# Indicate which methods can be used during the actual
+# request. (list value)
+#allow_methods=GET,POST,PUT,DELETE,OPTIONS
+
+# Indicate which header field names may be used during the
+# actual request. (list value)
+#allow_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma
+
+
[database]
#
diff --git a/ironic/api/app.py b/ironic/api/app.py
index 4307c6aae..a9e57ba36 100644
--- a/ironic/api/app.py
+++ b/ironic/api/app.py
@@ -16,10 +16,12 @@
# under the License.
from oslo_config import cfg
+import oslo_middleware.cors as cors_middleware
import pecan
from ironic.api import acl
from ironic.api import config
+from ironic.api.controllers.base import Version
from ironic.api import hooks
from ironic.api import middleware
from ironic.common.i18n import _
@@ -73,6 +75,15 @@ def setup_app(pecan_config=None, extra_hooks=None):
wrap_app=middleware.ParsableErrorMiddleware,
)
+ # Create a CORS wrapper, and attach ironic-specific defaults that must be
+ # included in all CORS responses.
+ app = cors_middleware.CORS(app, CONF)
+ app.set_latent(
+ allow_headers=[Version.max_string, Version.min_string, Version.string],
+ allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
+ expose_headers=[Version.max_string, Version.min_string, Version.string]
+ )
+
if pecan_config.app.enable_acl:
return acl.install(app, cfg.CONF, pecan_config.app.acl_public_routes)
diff --git a/requirements.txt b/requirements.txt
index e21b0e557..7b63287d7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -27,6 +27,7 @@ oslo.db>=2.4.1 # Apache-2.0
oslo.rootwrap>=2.0.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0
oslo.log>=1.8.0 # Apache-2.0
+oslo.middleware>=2.8.0 # Apache-2.0
oslo.policy>=0.5.0 # Apache-2.0
oslo.serialization>=1.4.0 # Apache-2.0
oslo.service>=0.7.0 # Apache-2.0
diff --git a/tools/config/oslo.config.generator.rc b/tools/config/oslo.config.generator.rc
index e85578e3a..2b977e866 100644
--- a/tools/config/oslo.config.generator.rc
+++ b/tools/config/oslo.config.generator.rc
@@ -1,2 +1,2 @@
-export IRONIC_CONFIG_GENERATOR_EXTRA_LIBRARIES='oslo.db oslo.messaging keystonemiddleware.auth_token oslo.concurrency oslo.policy oslo.log oslo.service.service oslo.service.periodic_task'
+export IRONIC_CONFIG_GENERATOR_EXTRA_LIBRARIES='oslo.db oslo.messaging oslo.middleware.cors keystonemiddleware.auth_token oslo.concurrency oslo.policy oslo.log oslo.service.service oslo.service.periodic_task'
export IRONIC_CONFIG_GENERATOR_EXTRA_MODULES=
diff --git a/vagrant.yaml b/vagrant.yaml
index 0d227a4fe..055a4a9dc 100644
--- a/vagrant.yaml
+++ b/vagrant.yaml
@@ -125,6 +125,14 @@
option: 'pecan_debug', value: 'true'
}
- {
+ section: 'DEFAULT',
+ option: 'verbose', value: 'true'
+ }
+ - {
+ section: 'DEFAULT',
+ option: 'debug', value: 'true'
+ }
+ - {
section: 'oslo_messaging_rabbit',
option: 'rabbit_host', value: "{{ip}}"
}
@@ -136,7 +144,10 @@
section: 'oslo_messaging_rabbit',
option: 'rabbit_password', value: "ironic"
}
-
+ - { # CORS Domain For Ironic-Webclient's dev server.
+ section: 'cors',
+ option: 'allowed_origin', value: "http://localhost:8000"
+ }
#############################################################################
# Handlers