103
103
import org .springframework .web .filter .CorsFilter ;
104
104
import org .springframework .web .servlet .handler .HandlerMappingIntrospector ;
105
105
106
+ import static org .springframework .security .config .Customizer .withDefaults ;
107
+
106
108
/**
107
109
* A {@link HttpSecurity} is similar to Spring Security's XML <http> element in the
108
110
* namespace configuration. It allows configuring web based security for specific http
@@ -219,8 +221,8 @@ private ApplicationContext getContext() {
219
221
/**
220
222
* Adds the Security headers to the response. This is activated by default when using
221
223
* {@link EnableWebSecurity}. Accepting the default provided by
222
- * {@link EnableWebSecurity} or only invoking {@link #headers() } without invoking
223
- * additional methods on it, is the equivalent of:
224
+ * {@link EnableWebSecurity} or only invoking {@link #headers(withDefaults()) } without
225
+ * invoking additional methods on it, is the equivalent of:
224
226
*
225
227
* <pre>
226
228
* @Configuration
@@ -266,8 +268,8 @@ private ApplicationContext getContext() {
266
268
*
267
269
* You can enable only a few of the headers by first invoking
268
270
* {@link HeadersConfigurer#defaultsDisabled()} and then invoking the appropriate
269
- * methods on the {@link #headers() } result. For example, the following will enable
270
- * {@link HeadersConfigurer#cacheControl()} and
271
+ * methods on the {@link #headers(withDefaults()) } result. For example, the following
272
+ * will enable {@link HeadersConfigurer#cacheControl()} and
271
273
* {@link HeadersConfigurer#frameOptions()} only.
272
274
*
273
275
* <pre>
@@ -331,7 +333,8 @@ public HeadersConfigurer<HttpSecurity> headers() throws Exception {
331
333
* <h2>Example Configurations</h2>
332
334
*
333
335
* Accepting the default provided by {@link EnableWebSecurity} or only invoking
334
- * {@link #headers()} without invoking additional methods on it, is the equivalent of:
336
+ * {@link #headers(Customizer)} without invoking additional methods on it, is the
337
+ * equivalent of:
335
338
*
336
339
* <pre>
337
340
* @Configuration
@@ -372,9 +375,9 @@ public HeadersConfigurer<HttpSecurity> headers() throws Exception {
372
375
*
373
376
* You can enable only a few of the headers by first invoking
374
377
* {@link HeadersConfigurer#defaultsDisabled()} and then invoking the appropriate
375
- * methods on the {@link #headers()} result. For example, the following will enable
376
- * {@link HeadersConfigurer#cacheControl()} and
377
- * {@link HeadersConfigurer#frameOptions()} only.
378
+ * methods on the {@link #headers(Customizer )} result. For example, the following will
379
+ * enable {@link HeadersConfigurer#cacheControl(Customizer )} and
380
+ * {@link HeadersConfigurer#frameOptions(Customizer )} only.
378
381
*
379
382
* <pre>
380
383
* @Configuration
@@ -397,7 +400,7 @@ public HeadersConfigurer<HttpSecurity> headers() throws Exception {
397
400
*
398
401
* You can also choose to keep the defaults but explicitly disable a subset of
399
402
* headers. For example, the following will enable all the default headers except
400
- * {@link HeadersConfigurer#frameOptions()}.
403
+ * {@link HeadersConfigurer#frameOptions(Customizer )}.
401
404
*
402
405
* <pre>
403
406
* @Configuration
@@ -615,9 +618,10 @@ public HttpSecurity sessionManagement(
615
618
* {@link HttpSecurity#getSharedObject(Class)}. Other provided
616
619
* {@link SecurityConfigurer} objects use this configured {@link PortMapper} as a
617
620
* default {@link PortMapper} when redirecting from HTTP to HTTPS or from HTTPS to
618
- * HTTP (for example when used in combination with {@link #requiresChannel()}. By
619
- * default Spring Security uses a {@link PortMapperImpl} which maps the HTTP port 8080
620
- * to the HTTPS port 8443 and the HTTP port of 80 to the HTTPS port of 443.
621
+ * HTTP (for example when used in combination with
622
+ * {@link #requiresChannel(Customizer)} )}. By default Spring Security uses a
623
+ * {@link PortMapperImpl} which maps the HTTP port 8080 to the HTTPS port 8443 and the
624
+ * HTTP port of 80 to the HTTPS port of 443.
621
625
*
622
626
* <h2>Example Configuration</h2>
623
627
*
@@ -657,7 +661,7 @@ public HttpSecurity sessionManagement(
657
661
* <a href=
658
662
* "https://docs.spring.io/spring-security/reference/migration-7/configuration.html#_use_the_lambda_dsl">documentation</a>
659
663
* for more details.
660
- * @see #requiresChannel()
664
+ * @see #requiresChannel(withDefaults() )
661
665
*/
662
666
@ Deprecated (since = "6.1" , forRemoval = true )
663
667
public PortMapperConfigurer <HttpSecurity > portMapper () throws Exception {
@@ -669,9 +673,10 @@ public PortMapperConfigurer<HttpSecurity> portMapper() throws Exception {
669
673
* {@link HttpSecurity#getSharedObject(Class)}. Other provided
670
674
* {@link SecurityConfigurer} objects use this configured {@link PortMapper} as a
671
675
* default {@link PortMapper} when redirecting from HTTP to HTTPS or from HTTPS to
672
- * HTTP (for example when used in combination with {@link #requiresChannel()}. By
673
- * default Spring Security uses a {@link PortMapperImpl} which maps the HTTP port 8080
674
- * to the HTTPS port 8443 and the HTTP port of 80 to the HTTPS port of 443.
676
+ * HTTP (for example when used in combination with
677
+ * {@link #requiresChannel(withDefaults())}. By default Spring Security uses a
678
+ * {@link PortMapperImpl} which maps the HTTP port 8080 to the HTTPS port 8443 and the
679
+ * HTTP port of 80 to the HTTPS port of 443.
675
680
*
676
681
* <h2>Example Configuration</h2>
677
682
*
@@ -714,7 +719,7 @@ public PortMapperConfigurer<HttpSecurity> portMapper() throws Exception {
714
719
* {@link PortMapperConfigurer}
715
720
* @return the {@link HttpSecurity} for further customizations
716
721
* @throws Exception
717
- * @see #requiresChannel()
722
+ * @see #requiresChannel(Customizer )
718
723
*/
719
724
public HttpSecurity portMapper (Customizer <PortMapperConfigurer <HttpSecurity >> portMapperCustomizer )
720
725
throws Exception {
@@ -1776,7 +1781,7 @@ public HttpSecurity csrf(Customizer<CsrfConfigurer<HttpSecurity>> csrfCustomizer
1776
1781
* Provides logout support. This is automatically applied when using
1777
1782
* {@link EnableWebSecurity}. The default is that accessing the URL "/logout" will log
1778
1783
* the user out by invalidating the HTTP Session, cleaning up any
1779
- * {@link #rememberMe()} authentication that was configured, clearing the
1784
+ * {@link #rememberMe(Customizer )} authentication that was configured, clearing the
1780
1785
* {@link SecurityContextHolder}, and then redirect to "/login?success".
1781
1786
*
1782
1787
* <h2>Example Custom Configuration</h2>
@@ -1827,8 +1832,8 @@ public LogoutConfigurer<HttpSecurity> logout() throws Exception {
1827
1832
* Provides logout support. This is automatically applied when using
1828
1833
* {@link EnableWebSecurity}. The default is that accessing the URL "/logout" will log
1829
1834
* the user out by invalidating the HTTP Session, cleaning up any
1830
- * {@link #rememberMe() } authentication that was configured, clearing the
1831
- * {@link SecurityContextHolder}, and then redirect to "/login?success".
1835
+ * {@link #rememberMe(withDefaults()) } authentication that was configured, clearing
1836
+ * the {@link SecurityContextHolder}, and then redirect to "/login?success".
1832
1837
*
1833
1838
* <h2>Example Custom Configuration</h2>
1834
1839
*
@@ -2499,7 +2504,7 @@ public HttpSecurity saml2Logout(Customizer<Saml2LogoutConfigurer<HttpSecurity>>
2499
2504
* {@link RelyingPartyRegistration}(s) are composed within a
2500
2505
* {@link RelyingPartyRegistrationRepository}, which is <b>required</b> and must be
2501
2506
* registered with the {@link ApplicationContext} or configured via
2502
- * {@link #saml2Login()}.<br>
2507
+ * {@link #saml2Login(withDefaults() )}.<br>
2503
2508
* <br>
2504
2509
*
2505
2510
* The default configuration provides an auto-generated logout endpoint at
0 commit comments