summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2015-11-20 22:55:22 -0500
committerDavanum Srinivas <davanum@gmail.com>2015-11-20 22:55:27 -0500
commit40135b76a92cef4197e2f68be46fd129d41630c6 (patch)
tree1dc907f97d8097a7afd63d486575b4c13cc6da7e
parent7ab5dcf8ed8fadc45cfa0bce641776704cecf24a (diff)
downloadoslo-middleware-40135b76a92cef4197e2f68be46fd129d41630c6.tar.gz
Backward compat for allowed_origin
In Ie2e57b76717604f701daa16ebf8ffa8c06835e3c, we switched from StrOpt to ListOpt for allowed_origin configuration option. For example ironic uses set_override to set the value to a string in test cases. We should allow the older behavior for some time to allow ironic test case TestCORSMiddleware to switch over. Change-Id: Ifac325871d89d9e85c6e74c05ba6e004aeb741b9
-rw-r--r--oslo_middleware/cors.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/oslo_middleware/cors.py b/oslo_middleware/cors.py
index ac86bc1..b91fabd 100644
--- a/oslo_middleware/cors.py
+++ b/oslo_middleware/cors.py
@@ -18,6 +18,7 @@ import logging
from oslo_config import cfg
from oslo_middleware import base
+import six
import webob.dec
import webob.exc
import webob.response
@@ -180,6 +181,12 @@ class CORS(base.ConfigurableMiddleware):
:param allow_headers: List of HTTP headers to permit from the client.
:return:
'''
+
+ # NOTE(dims): Support older code that still passes in
+ # a string for allowed_origin instead of a list
+ if isinstance(allowed_origin, six.string_types):
+ allowed_origin = [allowed_origin]
+
for origin in allowed_origin:
if origin in self.allowed_origins: