Skip to content

Commit c6e60c8

Browse files
committed
Add subsections to cors
This helps make the docs look more uniform after adding PreFlightRequestFilter docs in its own section Issue gh-18926
1 parent 4199240 commit c6e60c8

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

  • docs/modules/ROOT/pages/servlet/integrations

docs/modules/ROOT/pages/servlet/integrations/cors.adoc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ Spring Framework provides {spring-framework-reference-url}web/webmvc-cors.html[f
55
CORS must be processed before Spring Security, because the pre-flight request does not contain any cookies (that is, the `JSESSIONID`).
66
If the request does not contain any cookies and Spring Security is first, the request determines that the user is not authenticated (since there are no cookies in the request) and rejects it.
77

8+
[[cors-configuration-source]]
9+
== Providing a `CorsConfigurationSource`
10+
811
The easiest way to ensure that CORS is handled first is to use the `CorsFilter`.
9-
Users can integrate the `CorsFilter` with Spring Security by providing a `CorsConfigurationSource`. Note that Spring Security will automatically configure CORS only if a `UrlBasedCorsConfigurationSource` instance is present.
12+
Users can integrate the `CorsFilter` with Spring Security by providing a `CorsConfigurationSource`.
13+
Note that Spring Security will automatically configure CORS only if a `UrlBasedCorsConfigurationSource` instance is present.
1014
For example, the following will integrate CORS support within Spring Security:
1115

1216
[tabs]
@@ -55,6 +59,9 @@ The following listing does the same thing in XML:
5559
</b:bean>
5660
----
5761

62+
[[cors-spring-mvc-integration]]
63+
== Spring MVC Integration
64+
5865
If you use Spring MVC's CORS support, you can omit specifying the `CorsConfigurationSource` and Spring Security uses the CORS configuration provided to Spring MVC:
5966

6067
[tabs]
@@ -111,8 +118,11 @@ The following listing does the same thing in XML:
111118
</http>
112119
----
113120

114-
If you have more than one `CorsConfigurationSource` bean, Spring Security won't automatically configure CORS support for you, that is because it cannot decide which one to use.
115-
If you want to specify different `CorsConfigurationSource` for each `SecurityFilterChain`, you can pass it directly into the `.cors()` DSL.
121+
[[cors-per-chain-configuration]]
122+
== Per-Chain Configuration
123+
124+
If you have more than one `CorsConfigurationSource` bean, Spring Security won't automatically configure CORS support for you, because it cannot decide which one to use.
125+
If you want to specify a different `CorsConfigurationSource` for each `SecurityFilterChain`, you can pass it directly into the `.cors()` DSL.
116126

117127
[tabs]
118128
======

0 commit comments

Comments
 (0)