86 | Date: Tue, 5 Mar 2019 12:22:26 -0600
87 | Subject: [PATCH] Fix improper CORS return
88 |
89 | Prior to this commit if you sent a request from an origin not listed in
90 | `allowed_origins` we would respond with `null` for the
91 | `Access-Control-Allow-Origin` header. Per
92 | [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin#Directives](mozilla's documentation)
93 | null should not be used as some clients will allow the request to go
94 | through. This commit returns the first of our allowed origins if the
95 | requesting origin is not a supported origin.
96 | ---
97 | st2api/tests/unit/controllers/v1/test_base.py | 4 ++--
98 | st2common/st2common/middleware/cors.py | 2 +-
99 | 2 files changed, 3 insertions(+), 3 deletions(-)
100 |
101 | diff --git a/st2api/tests/unit/controllers/v1/test_base.py b/st2api/tests/unit/controllers/v1/test_base.py
102 | index 2a753f22ea..e66148a0a5 100644
103 | --- a/st2api/tests/unit/controllers/v1/test_base.py
104 | +++ b/st2api/tests/unit/controllers/v1/test_base.py
105 | @@ -51,8 +51,8 @@ def test_wrong_origin(self):
106 | 'origin': 'http://xss'
107 | })
108 | self.assertEqual(response.status_int, 200)
109 | - self.assertEqual(response.headers['Access-Control-Allow-Origin'],
110 | - 'null')
111 | + self.assertEqual(response.headers.get('Access-Control-Allow-Origin'),
112 | + 'http://127.0.0.1:3000')
113 |
114 | def test_wildcard_origin(self):
115 | try:
116 | diff --git a/st2common/st2common/middleware/cors.py b/st2common/st2common/middleware/cors.py
117 | index 5781b1a6e7..8cb407b52c 100644
118 | --- a/st2common/st2common/middleware/cors.py
119 | +++ b/st2common/st2common/middleware/cors.py
120 | @@ -66,7 +66,7 @@ def custom_start_response(status, headers, exc_info=None):
121 | origin_allowed = origin
122 | else:
123 | # See http://www.w3.org/TR/cors/#access-control-allow-origin-response-header
124 | - origin_allowed = origin if origin in origins else 'null'
125 | + origin_allowed = origin if origin in origins else list(origins)[0]
126 | else:
127 | origin_allowed = list(origins)[0]
128 | ```
129 |
130 | ### Ressources:
131 |
132 | * https://stackstorm.com/2019/03/08/stackstorm-2-9-3-2-10-3/
133 | * https://quitten.github.io/StackStorm/
134 |
135 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 | ,;;*;;;;,
3 | .-'``;-');;.
4 | /' .-. /*;;
5 | .' \d \;; .;;;,
6 | / o ` \; ,__. ,;*;;;*;,
7 | \__, _.__,' \_.-') __)--.;;;;;*;;;;,
8 | `""`;;;\ /-')_) __) `\' ';;;;;;
9 | ;*;;; -') `)_) |\ | ;;;;*;
10 | ;;;;| `---` O | | ;;*;;;
11 | *;*;\| O / ;;;;;*
12 | ;;;;;/| .-------\ / ;*;;;;;
13 | ;;;*;/ \ | '. (`. ;;;*;;;
14 | ;;;;;'. ; | ) \ | ;;;;;;
15 | ,;*;;;;\/ |. / /` | ';;;*;
16 | ;;;;;;/ |/ / /__/ ';;;
17 | '"*"'/ | / | ;*;
18 | `""""` `""""` ;'
19 |
20 |
21 |
52 |
--------------------------------------------------------------------------------