Skip to content

Commit c892ce5

Browse files
committed
Refine CORS documentation for wildcard processing
This commit adds a reference documentation section dedicated to CORS credentialed requests and related wildcard processing. Closes gh-31143
1 parent 76b8bb2 commit c892ce5

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

framework-docs/modules/ROOT/pages/web/webflux-cors.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,35 @@ To learn more from the source or to make advanced customizations, see:
7575

7676

7777

78+
[[webflux-cors-credentialed-requests]]
79+
== Credentialed Requests
80+
[.small]#xref:web/webmvc-cors.adoc#mvc-cors-credentialed-requests[See equivalent in the Servlet stack]#
81+
82+
Using CORS with credentialed requests requires enabling `allowedCredentials`. Be aware that
83+
this option establishes a high level of trust with the configured domains and also increases
84+
the surface of attack of the web application by exposing sensitive user-specific information
85+
such as cookies and CSRF tokens.
86+
87+
Enabling credentials also impacts how the configured `"*"` CORS wildcards are processed:
88+
89+
* Wildcards are not authorized in `allowOrigins`, but alternatively
90+
the `allowOriginPatterns` property may be used to match to a dynamic set of origins.
91+
* When set on `allowedHeaders` or `allowedMethods`, the `Access-Control-Allow-Headers`
92+
and `Access-Control-Allow-Methods` response headers are handled by copying the related
93+
headers and method specified in the CORS preflight request.
94+
* When set on `exposedHeaders`, `Access-Control-Expose-Headers` response header is set
95+
either to the configured list of headers or to the wildcard character. While the CORS spec
96+
does not allow the wildcard character when `Access-Control-Allow-Credentials` is set to
97+
`true`, most browsers support it and the response headers are not all available during the
98+
CORS processing, so as a consequence the wildcard character is the header value used when
99+
specified regardless of the value of the `allowCredentials` property.
100+
101+
WARNING: While such wildcard configuration can be handy, it is recommended when possible to configure
102+
a finite set of values instead to provide a higher level of security.
103+
104+
105+
106+
78107
[[webflux-cors-controller]]
79108
== `@CrossOrigin`
80109
[.small]#xref:web/webmvc-cors.adoc#mvc-cors-controller[See equivalent in the Servlet stack]#

framework-docs/modules/ROOT/pages/web/webmvc-cors.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@ powerful workarounds based on IFRAME or JSONP.
2525

2626

2727

28+
[[mvc-cors-credentialed-requests]]
29+
== Credentialed Requests
30+
[.small]#xref:web/webflux-cors.adoc#webflux-cors-credentialed-requests[See equivalent in the Reactive stack]#
31+
32+
Using CORS with credentialed requests requires enabling `allowedCredentials`. Be aware that
33+
this option establishes a high level of trust with the configured domains and also increases
34+
the surface of attack of the web application by exposing sensitive user-specific information
35+
such as cookies and CSRF tokens.
36+
37+
Enabling credentials also impacts how the configured `"*"` CORS wildcards are processed:
38+
39+
* Wildcards are not authorized in `allowOrigins`, but alternatively
40+
the `allowOriginPatterns` property may be used to match to a dynamic set of origins.
41+
* When set on `allowedHeaders` or `allowedMethods`, the `Access-Control-Allow-Headers`
42+
and `Access-Control-Allow-Methods` response headers are handled by copying the related
43+
headers and method specified in the CORS preflight request.
44+
* When set on `exposedHeaders`, `Access-Control-Expose-Headers` response header is set
45+
either to the configured list of headers or to the wildcard character. While the CORS spec
46+
does not allow the wildcard character when `Access-Control-Allow-Credentials` is set to
47+
`true`, most browsers support it and the response headers are not all available during the
48+
CORS processing, so as a consequence the wildcard character is the header value used when
49+
specified regardless of the value of the `allowCredentials` property.
50+
51+
WARNING: While such wildcard configuration can be handy, it is recommended when possible to configure
52+
a finite set of values instead to provide a higher level of security.
53+
54+
55+
56+
2857
[[mvc-cors-processing]]
2958
== Processing
3059
[.small]#xref:web/webflux-cors.adoc#webflux-cors-processing[See equivalent in the Reactive stack]#

0 commit comments

Comments
 (0)