Skip to content

Commit d59f1ee

Browse files
authored
Verduidelijk gebruik van CORS header in combinatie met openapi.json (#245)
Hiermee makene we duidelijk dat de CORS regel is geschreven per resource in plaats van per API. Daarmee kunnen we expliciet maken dat de `openapi.json` resource bijvoorbeeld publiekelijk beschikbaar moet zijn. Ook voegen we een noot toe die omissie van de header expliciet maakt als de resource enkel door de eigen origin wordt gebruikt.
1 parent 1ed2275 commit d59f1ee

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

sections/designRules.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ For outbound filtering, the main concern is leaking of information.
829829
</tr>
830830
<tr>
831831
<td>`Access-Control-Allow-Origin`</td>
832-
<td>To relax the &#39;same origin&#39; policy and allow cross-origin access. See CORS-policy below</td>
832+
<td>To relax the &#39;same origin&#39; policy and allow cross-origin access. See <a href="#/core/transport/cors">/core/transport/cors</a> for more information.</td>
833833
</tr>
834834
</tbody>
835835
</table>
@@ -871,12 +871,22 @@ For outbound filtering, the main concern is leaking of information.
871871
<dl>
872872
<dt>Statement</dt>
873873
<dd>
874-
Use CORS to restrict access from other domains (if applicable).
874+
Use CORS to restrict access from other domains for applicable resources
875875
</dd>
876876
<dt>Rationale</dt>
877877
<dd>
878-
<p>Modern web browsers use Cross-Origin Resource Sharing (CORS) to minimize the risk associated with cross-site HTTP-requests. By default browsers only allow 'same origin' access to resources. This means that responses on requests to another `[scheme]://[hostname]:[port]` than the `Origin` request header of the initial request will not be processed by the browser. To enable cross-site requests APIs can return a `Access-Control-Allow-Origin` response header. An allowlist SHOULD be used to determine the validity of different cross-site requests. To do this check the `Origin` header of the incoming request and check if the domain in this header is on the allowlist. If this is the case, set the incoming `Origin` header in the `Access-Control-Allow-Origin` response header.
879-
<p>Using a wildcard `*` in the `Access-Control-Allow-Origin` response header is NOT RECOMMENDED, because it disables CORS-security measures. Only for an open API which has to be accessed by numerous other websites this is appropriate.
878+
<p>Different resources can have different uses, as some resources are publicly available whereas others are restricted to several domains.
879+
Modern web browsers use Cross-Origin Resource Sharing (CORS) to minimize the risk associated with cross-site HTTP-requests.
880+
<p>By default browsers only allow 'same origin' access to resources.
881+
This means that responses on requests to another `[scheme]://[hostname]:[port]` than the `Origin` request header of the initial request will not be processed by the browser.
882+
To enable cross-site requests APIs can return a `Access-Control-Allow-Origin` response header.
883+
<p>An allowlist SHOULD be used to determine the validity of different cross-site requests.
884+
To do this, check the `Origin` header of the incoming request and check if the domain in this header is on the allowlist.
885+
If this is the case, set the incoming `Origin` header in the `Access-Control-Allow-Origin` response header.
886+
<div class="note">
887+
Using a wildcard `*` in the `Access-Control-Allow-Origin` response header is NOT RECOMMENDED, because it disables CORS-security measures.
888+
However, if the resource has to be accessed by numerous other origins that are not known up front (such as all resources in an open API, or the `openapi.json` as required by <a href="#/core/publish-openapi">/core/publish-openapi</a>), you MAY use `*`.
889+
</div>
880890
</dd>
881891
<dt>How to test</dt>
882892
<dd>

0 commit comments

Comments
 (0)