Commit 088cf1e
committed
issue2551203 - Add support for CORS preflight request
Add support for unauthenticated CORS preflight and fix headers for
CORS.
client.py:
pass through unauthenticated CORS preflight to rest backend. Normal
rest OPTION handlers (including tracker defined extensions) can
see and handle the request.
make some error cases return error json with crrect mime type rather
than plain text tracebacks.
create new functions to verify origin and referer that filter using
allowed origins setting.
remove tracker base url from error message is referer is not at an
allowed origin.
rest.py:
fix up OPTION methods handlers to include
Access-Control-Allow-Methods that are the same as the Allow
header.
set cache to one week for all Access-Control headers for CORS
preflight only.
remove self.client.setHeader("Access-Control-Allow-Origin", "*") and
set Access-Control-Allow-Origin to the client supplied origin if
it passes allowed origin checks. Required for CORS otherwise data
isn't available to caller. Set for all responses.
set Vary header now includes Origin as responses can differ based on
Origin for all responses.
set Access-Control-Allow-Credentials to true on all responses.
test_liveserver.py:
run server with setting to enforce origin csrf header check
run server with setting to enforce x-requested-with csrf header check
run server with setting for allowed_api_origins
requests now set required csrf headers
test preflight request on collections
check new headers and Origin is no longer '*'
rewrite all compression checks to use a single method with argument
to use different compression methods. Reduce a lot of code
duplication and makes updating for new headers easier.
test_cgi:
test new error messages in client.py
account for new headers
test preflight and new code paths1 parent 004b3de commit 088cf1e
File tree
5 files changed
+349
-357
lines changed- roundup
- cgi
- test
5 files changed
+349
-357
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
624 | 649 | | |
625 | 650 | | |
626 | 651 | | |
| |||
636 | 661 | | |
637 | 662 | | |
638 | 663 | | |
639 | | - | |
640 | | - | |
641 | 664 | | |
642 | 665 | | |
643 | | - | |
| 666 | + | |
644 | 667 | | |
645 | 668 | | |
646 | | - | |
| 669 | + | |
647 | 670 | | |
648 | 671 | | |
649 | 672 | | |
| |||
1223 | 1246 | | |
1224 | 1247 | | |
1225 | 1248 | | |
1226 | | - | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1227 | 1264 | | |
1228 | 1265 | | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1229 | 1282 | | |
1230 | 1283 | | |
1231 | 1284 | | |
| |||
1335 | 1388 | | |
1336 | 1389 | | |
1337 | 1390 | | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
| 1391 | + | |
| 1392 | + | |
1342 | 1393 | | |
1343 | 1394 | | |
1344 | | - | |
| 1395 | + | |
1345 | 1396 | | |
1346 | 1397 | | |
1347 | 1398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1751 | 1751 | | |
1752 | 1752 | | |
1753 | 1753 | | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
1754 | 1758 | | |
1755 | 1759 | | |
1756 | 1760 | | |
| |||
1774 | 1778 | | |
1775 | 1779 | | |
1776 | 1780 | | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1777 | 1785 | | |
1778 | 1786 | | |
1779 | 1787 | | |
1780 | 1788 | | |
1781 | 1789 | | |
1782 | 1790 | | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
1783 | 1795 | | |
1784 | 1796 | | |
1785 | 1797 | | |
| |||
1910 | 1922 | | |
1911 | 1923 | | |
1912 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
1913 | 1929 | | |
1914 | 1930 | | |
1915 | 1931 | | |
| |||
1939 | 1955 | | |
1940 | 1956 | | |
1941 | 1957 | | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
1942 | 1962 | | |
1943 | 1963 | | |
1944 | 1964 | | |
| |||
2161 | 2181 | | |
2162 | 2182 | | |
2163 | 2183 | | |
2164 | | - | |
2165 | | - | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
2166 | 2206 | | |
2167 | | - | |
2168 | | - | |
| 2207 | + | |
| 2208 | + | |
2169 | 2209 | | |
| 2210 | + | |
| 2211 | + | |
2170 | 2212 | | |
2171 | | - | |
2172 | | - | |
| 2213 | + | |
| 2214 | + | |
2173 | 2215 | | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
2174 | 2219 | | |
2175 | | - | |
2176 | | - | |
| 2220 | + | |
| 2221 | + | |
2177 | 2222 | | |
| 2223 | + | |
2178 | 2224 | | |
2179 | 2225 | | |
2180 | 2226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1169 | 1169 | | |
1170 | 1170 | | |
1171 | 1171 | | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1172 | 1186 | | |
1173 | 1187 | | |
1174 | 1188 | | |
| |||
1215 | 1229 | | |
1216 | 1230 | | |
1217 | 1231 | | |
1218 | | - | |
| 1232 | + | |
1219 | 1233 | | |
1220 | 1234 | | |
1221 | 1235 | | |
| |||
1320 | 1334 | | |
1321 | 1335 | | |
1322 | 1336 | | |
1323 | | - | |
| 1337 | + | |
1324 | 1338 | | |
1325 | 1339 | | |
1326 | 1340 | | |
| |||
1332 | 1346 | | |
1333 | 1347 | | |
1334 | 1348 | | |
1335 | | - | |
| 1349 | + | |
1336 | 1350 | | |
1337 | 1351 | | |
1338 | 1352 | | |
| |||
1346 | 1360 | | |
1347 | 1361 | | |
1348 | 1362 | | |
1349 | | - | |
| 1363 | + | |
1350 | 1364 | | |
1351 | 1365 | | |
1352 | 1366 | | |
1353 | 1367 | | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1354 | 1425 | | |
1355 | 1426 | | |
1356 | 1427 | | |
| |||
0 commit comments