6 | | But over https, we want to be a bit more strict and make sure that the |
7 | | Referer is from another secure site, and also that the Referer matches |
8 | | where we think it should be coming from. Django should validate that the |
9 | | Referer header matches one of the domains listed in |
10 | | `CSRF_TRUSTED_ORIGINS`, including the currently responding |
11 | | `ALLOWED_HOST`. |
| 5 | But there also cases where a totally separate domain may be allowed to make `POST` (etc) requests to an API via CORS, and CORS headers can be configured to allow XHR requests from that external domain to send cookies to the API (including the CSRF cookie). But at the moment such a technique falls afoul of the Referer checking, and the only way to bypass it is by monkeypatching the request headers (that's what https://github.com/ottoyiu/django-cors-headers does). |
| 6 | |
| 7 | This ticket proposes adding a `CSRF_TRUSTED_ORIGINS` setting, which can be set to a list of hosts that should be considered valid Referers for the purposes of CSRF checking. |