@@ -285,8 +285,10 @@ private ApplicationContext getContext() {
285
285
* </pre>
286
286
* @return the {@link HeadersConfigurer} for further customizations
287
287
* @throws Exception
288
+ * @deprecated For removal in 7.0. Use {@link #headers(Customizer)} instead
288
289
* @see HeadersConfigurer
289
290
*/
291
+ @ Deprecated (since = "6.1" , forRemoval = true )
290
292
public HeadersConfigurer <HttpSecurity > headers () throws Exception {
291
293
return getOrApply (new HeadersConfigurer <>());
292
294
}
@@ -399,7 +401,9 @@ public HttpSecurity headers(Customizer<HeadersConfigurer<HttpSecurity>> headersC
399
401
* on the classpath a {@link HandlerMappingIntrospector} is used.
400
402
* @return the {@link CorsConfigurer} for customizations
401
403
* @throws Exception
404
+ * @deprecated For removal in 7.0. Use {@link #cors(Customizer)} instead
402
405
*/
406
+ @ Deprecated (since = "6.1" , forRemoval = true )
403
407
public CorsConfigurer <HttpSecurity > cors () throws Exception {
404
408
return getOrApply (new CorsConfigurer <>());
405
409
}
@@ -486,7 +490,9 @@ public HttpSecurity cors(Customizer<CorsConfigurer<HttpSecurity>> corsCustomizer
486
490
* could return true.
487
491
* @return the {@link SessionManagementConfigurer} for further customizations
488
492
* @throws Exception
493
+ * @deprecated For removal in 7.0. Use {@link #sessionManagement(Customizer)} instead
489
494
*/
495
+ @ Deprecated (since = "6.1" , forRemoval = true )
490
496
public SessionManagementConfigurer <HttpSecurity > sessionManagement () throws Exception {
491
497
return getOrApply (new SessionManagementConfigurer <>());
492
498
}
@@ -608,8 +614,10 @@ public HttpSecurity sessionManagement(
608
614
* </pre>
609
615
* @return the {@link PortMapperConfigurer} for further customizations
610
616
* @throws Exception
617
+ * @deprecated For removal in 7.0. Use {@link #portMapper(Customizer)} instead
611
618
* @see #requiresChannel()
612
619
*/
620
+ @ Deprecated (since = "6.1" , forRemoval = true )
613
621
public PortMapperConfigurer <HttpSecurity > portMapper () throws Exception {
614
622
return getOrApply (new PortMapperConfigurer <>());
615
623
}
@@ -739,7 +747,9 @@ public HttpSecurity portMapper(Customizer<PortMapperConfigurer<HttpSecurity>> po
739
747
* Servlet Container's documentation.
740
748
* @return the {@link JeeConfigurer} for further customizations
741
749
* @throws Exception
750
+ * @deprecated For removal in 7.0. Use {@link #jee(Customizer)} instead
742
751
*/
752
+ @ Deprecated (since = "6.1" , forRemoval = true )
743
753
public JeeConfigurer <HttpSecurity > jee () throws Exception {
744
754
return getOrApply (new JeeConfigurer <>());
745
755
}
@@ -850,7 +860,9 @@ public HttpSecurity jee(Customizer<JeeConfigurer<HttpSecurity>> jeeCustomizer) t
850
860
* </pre>
851
861
* @return the {@link X509Configurer} for further customizations
852
862
* @throws Exception
863
+ * @deprecated For removal in 7.0. Use {@link #x509(Customizer)} instead
853
864
*/
865
+ @ Deprecated (since = "6.1" , forRemoval = true )
854
866
public X509Configurer <HttpSecurity > x509 () throws Exception {
855
867
return getOrApply (new X509Configurer <>());
856
868
}
@@ -928,7 +940,9 @@ public HttpSecurity x509(Customizer<X509Configurer<HttpSecurity>> x509Customizer
928
940
* </pre>
929
941
* @return the {@link RememberMeConfigurer} for further customizations
930
942
* @throws Exception
943
+ * @deprecated For removal in 7.0. Use {@link #rememberMe(Customizer)} instead
931
944
*/
945
+ @ Deprecated (since = "6.1" , forRemoval = true )
932
946
public RememberMeConfigurer <HttpSecurity > rememberMe () throws Exception {
933
947
return getOrApply (new RememberMeConfigurer <>());
934
948
}
@@ -1072,7 +1086,7 @@ public HttpSecurity rememberMe(Customizer<RememberMeConfigurer<HttpSecurity>> re
1072
1086
* </pre>
1073
1087
* @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations
1074
1088
* @throws Exception
1075
- * @deprecated Use {@link #authorizeHttpRequests()} instead
1089
+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests()} instead
1076
1090
*/
1077
1091
@ Deprecated
1078
1092
public ExpressionUrlAuthorizationConfigurer <HttpSecurity >.ExpressionInterceptUrlRegistry authorizeRequests ()
@@ -1187,7 +1201,7 @@ public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrl
1187
1201
* for the {@link ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry}
1188
1202
* @return the {@link HttpSecurity} for further customizations
1189
1203
* @throws Exception
1190
- * @deprecated Use {@link #authorizeHttpRequests} instead
1204
+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests} instead
1191
1205
*/
1192
1206
@ Deprecated
1193
1207
public HttpSecurity authorizeRequests (
@@ -1302,7 +1316,10 @@ public HttpSecurity authorizeRequests(
1302
1316
* @return the {@link HttpSecurity} for further customizations
1303
1317
* @throws Exception
1304
1318
* @since 5.6
1319
+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests(Customizer)}
1320
+ * instead
1305
1321
*/
1322
+ @ Deprecated (since = "6.1" , forRemoval = true )
1306
1323
public AuthorizeHttpRequestsConfigurer <HttpSecurity >.AuthorizationManagerRequestMatcherRegistry authorizeHttpRequests ()
1307
1324
throws Exception {
1308
1325
ApplicationContext context = getContext ();
@@ -1434,7 +1451,9 @@ public HttpSecurity authorizeHttpRequests(
1434
1451
* when using {@link EnableWebSecurity}.
1435
1452
* @return the {@link RequestCacheConfigurer} for further customizations
1436
1453
* @throws Exception
1454
+ * @deprecated For removal in 7.0. Use {@link #requestCache(Customizer)} instead
1437
1455
*/
1456
+ @ Deprecated (since = "6.1" , forRemoval = true )
1438
1457
public RequestCacheConfigurer <HttpSecurity > requestCache () throws Exception {
1439
1458
return getOrApply (new RequestCacheConfigurer <>());
1440
1459
}
@@ -1485,7 +1504,9 @@ public HttpSecurity requestCache(Customizer<RequestCacheConfigurer<HttpSecurity>
1485
1504
* {@link EnableWebSecurity}.
1486
1505
* @return the {@link ExceptionHandlingConfigurer} for further customizations
1487
1506
* @throws Exception
1507
+ * @deprecated For removal in 7.0. Use {@link #exceptionHandling(Customizer)} instead
1488
1508
*/
1509
+ @ Deprecated (since = "6.1" , forRemoval = true )
1489
1510
public ExceptionHandlingConfigurer <HttpSecurity > exceptionHandling () throws Exception {
1490
1511
return getOrApply (new ExceptionHandlingConfigurer <>());
1491
1512
}
@@ -1537,7 +1558,9 @@ public HttpSecurity exceptionHandling(
1537
1558
* automatically applied when using {@link EnableWebSecurity}.
1538
1559
* @return the {@link SecurityContextConfigurer} for further customizations
1539
1560
* @throws Exception
1561
+ * @deprecated For removal in 7.0. Use {@link #securityContext(Customizer)} instead
1540
1562
*/
1563
+ @ Deprecated (since = "6.1" , forRemoval = true )
1541
1564
public SecurityContextConfigurer <HttpSecurity > securityContext () throws Exception {
1542
1565
return getOrApply (new SecurityContextConfigurer <>());
1543
1566
}
@@ -1582,7 +1605,9 @@ public HttpSecurity securityContext(Customizer<SecurityContextConfigurer<HttpSec
1582
1605
* {@link EnableWebSecurity}.
1583
1606
* @return the {@link ServletApiConfigurer} for further customizations
1584
1607
* @throws Exception
1608
+ * @deprecated For removal in 7.0. Use {@link #servletApi(Customizer)} instead
1585
1609
*/
1610
+ @ Deprecated (since = "6.1" , forRemoval = true )
1586
1611
public ServletApiConfigurer <HttpSecurity > servletApi () throws Exception {
1587
1612
return getOrApply (new ServletApiConfigurer <>());
1588
1613
}
@@ -1638,7 +1663,9 @@ public HttpSecurity servletApi(Customizer<ServletApiConfigurer<HttpSecurity>> se
1638
1663
* </pre>
1639
1664
* @return the {@link CsrfConfigurer} for further customizations
1640
1665
* @throws Exception
1666
+ * @deprecated For removal in 7.0. Use {@link #csrf(Customizer)} instead
1641
1667
*/
1668
+ @ Deprecated (since = "6.1" , forRemoval = true )
1642
1669
public CsrfConfigurer <HttpSecurity > csrf () throws Exception {
1643
1670
ApplicationContext context = getContext ();
1644
1671
return getOrApply (new CsrfConfigurer <>(context ));
@@ -1713,7 +1740,9 @@ public HttpSecurity csrf(Customizer<CsrfConfigurer<HttpSecurity>> csrfCustomizer
1713
1740
* </pre>
1714
1741
* @return the {@link LogoutConfigurer} for further customizations
1715
1742
* @throws Exception
1743
+ * @deprecated For removal in 7.0. Use {@link #logout(Customizer)} instead
1716
1744
*/
1745
+ @ Deprecated (since = "6.1" , forRemoval = true )
1717
1746
public LogoutConfigurer <HttpSecurity > logout () throws Exception {
1718
1747
return getOrApply (new LogoutConfigurer <>());
1719
1748
}
@@ -1852,7 +1881,9 @@ public HttpSecurity logout(Customizer<LogoutConfigurer<HttpSecurity>> logoutCust
1852
1881
* </pre>
1853
1882
* @return the {@link AnonymousConfigurer} for further customizations
1854
1883
* @throws Exception
1884
+ * @deprecated For removal in 7.0. Use {@link #anonymous(Customizer)} instead
1855
1885
*/
1886
+ @ Deprecated (since = "6.1" , forRemoval = true )
1856
1887
public AnonymousConfigurer <HttpSecurity > anonymous () throws Exception {
1857
1888
return getOrApply (new AnonymousConfigurer <>());
1858
1889
}
@@ -2015,8 +2046,10 @@ public HttpSecurity anonymous(Customizer<AnonymousConfigurer<HttpSecurity>> anon
2015
2046
* </pre>
2016
2047
* @return the {@link FormLoginConfigurer} for further customizations
2017
2048
* @throws Exception
2049
+ * @deprecated For removal in 7.0. Use {@link #formLogin(Customizer)} instead
2018
2050
* @see FormLoginConfigurer#loginPage(String)
2019
2051
*/
2052
+ @ Deprecated (since = "6.1" , forRemoval = true )
2020
2053
public FormLoginConfigurer <HttpSecurity > formLogin () throws Exception {
2021
2054
return getOrApply (new FormLoginConfigurer <>());
2022
2055
}
@@ -2191,7 +2224,9 @@ public HttpSecurity formLogin(Customizer<FormLoginConfigurer<HttpSecurity>> form
2191
2224
* @return the {@link Saml2LoginConfigurer} for further customizations
2192
2225
* @throws Exception
2193
2226
* @since 5.2
2227
+ * @deprecated For removal in 7.0. Use {@link #saml2Login(Customizer)} instead
2194
2228
*/
2229
+ @ Deprecated (since = "6.1" , forRemoval = true )
2195
2230
public Saml2LoginConfigurer <HttpSecurity > saml2Login () throws Exception {
2196
2231
return getOrApply (new Saml2LoginConfigurer <>());
2197
2232
}
@@ -2421,7 +2456,9 @@ public HttpSecurity saml2Logout(Customizer<Saml2LogoutConfigurer<HttpSecurity>>
2421
2456
* @return the {@link Saml2LoginConfigurer} for further customizations
2422
2457
* @throws Exception
2423
2458
* @since 5.6
2459
+ * @deprecated For removal in 7.0. Use {@link #saml2Logout(Customizer)} instead
2424
2460
*/
2461
+ @ Deprecated (since = "6.1" , forRemoval = true )
2425
2462
public Saml2LogoutConfigurer <HttpSecurity > saml2Logout () throws Exception {
2426
2463
return getOrApply (new Saml2LogoutConfigurer <>(getContext ()));
2427
2464
}
@@ -2517,7 +2554,9 @@ public HttpSecurity saml2Metadata(Customizer<Saml2MetadataConfigurer<HttpSecurit
2517
2554
* @return the {@link Saml2MetadataConfigurer} for further customizations
2518
2555
* @throws Exception
2519
2556
* @since 6.1
2557
+ * @deprecated For removal in 7.0. Use {@link #saml2Metadata(Customizer)} instead
2520
2558
*/
2559
+ @ Deprecated (since = "6.1" , forRemoval = true )
2521
2560
public Saml2MetadataConfigurer <HttpSecurity > saml2Metadata () throws Exception {
2522
2561
return getOrApply (new Saml2MetadataConfigurer <>(getContext ()));
2523
2562
}
@@ -2608,6 +2647,7 @@ public Saml2MetadataConfigurer<HttpSecurity> saml2Metadata() throws Exception {
2608
2647
* @return the {@link OAuth2LoginConfigurer} for further customizations
2609
2648
* @throws Exception
2610
2649
* @since 5.0
2650
+ * @deprecated For removal in 7.0. Use {@link #oauth2Login(Customizer)} instead
2611
2651
* @see <a target="_blank" href=
2612
2652
* "https://tools.ietf.org/html/rfc6749#section-4.1">Section 4.1 Authorization Code
2613
2653
* Grant</a>
@@ -2617,6 +2657,7 @@ public Saml2MetadataConfigurer<HttpSecurity> saml2Metadata() throws Exception {
2617
2657
* @see org.springframework.security.oauth2.client.registration.ClientRegistration
2618
2658
* @see org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
2619
2659
*/
2660
+ @ Deprecated (since = "6.1" , forRemoval = true )
2620
2661
public OAuth2LoginConfigurer <HttpSecurity > oauth2Login () throws Exception {
2621
2662
return getOrApply (new OAuth2LoginConfigurer <>());
2622
2663
}
@@ -2729,10 +2770,12 @@ public HttpSecurity oauth2Login(Customizer<OAuth2LoginConfigurer<HttpSecurity>>
2729
2770
* @return the {@link OAuth2ClientConfigurer} for further customizations
2730
2771
* @throws Exception
2731
2772
* @since 5.1
2773
+ * @deprecated For removal in 7.0. Use {@link #oauth2Client(Customizer)} instead
2732
2774
* @see <a target="_blank" href=
2733
2775
* "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
2734
2776
* Framework</a>
2735
2777
*/
2778
+ @ Deprecated (since = "6.1" , forRemoval = true )
2736
2779
public OAuth2ClientConfigurer <HttpSecurity > oauth2Client () throws Exception {
2737
2780
OAuth2ClientConfigurer <HttpSecurity > configurer = getOrApply (new OAuth2ClientConfigurer <>());
2738
2781
this .postProcess (configurer );
@@ -2783,10 +2826,13 @@ public HttpSecurity oauth2Client(Customizer<OAuth2ClientConfigurer<HttpSecurity>
2783
2826
* @return the {@link OAuth2ResourceServerConfigurer} for further customizations
2784
2827
* @throws Exception
2785
2828
* @since 5.1
2829
+ * @deprecated For removal in 7.0. Use {@link #oauth2ResourceServer(Customizer)}
2830
+ * instead
2786
2831
* @see <a target="_blank" href=
2787
2832
* "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
2788
2833
* Framework</a>
2789
2834
*/
2835
+ @ Deprecated (since = "6.1" , forRemoval = true )
2790
2836
public OAuth2ResourceServerConfigurer <HttpSecurity > oauth2ResourceServer () throws Exception {
2791
2837
OAuth2ResourceServerConfigurer <HttpSecurity > configurer = getOrApply (
2792
2838
new OAuth2ResourceServerConfigurer <>(getContext ()));
@@ -2884,7 +2930,9 @@ public HttpSecurity oauth2ResourceServer(
2884
2930
* </pre>
2885
2931
* @return the {@link ChannelSecurityConfigurer} for further customizations
2886
2932
* @throws Exception
2933
+ * @deprecated For removal in 7.0. Use {@link #requiresChannel(Customizer)} instead
2887
2934
*/
2935
+ @ Deprecated (since = "6.1" , forRemoval = true )
2888
2936
public ChannelSecurityConfigurer <HttpSecurity >.ChannelRequestMatcherRegistry requiresChannel () throws Exception {
2889
2937
ApplicationContext context = getContext ();
2890
2938
return getOrApply (new ChannelSecurityConfigurer <>(context )).getRegistry ();
@@ -2979,7 +3027,9 @@ public HttpSecurity requiresChannel(
2979
3027
* </pre>
2980
3028
* @return the {@link HttpBasicConfigurer} for further customizations
2981
3029
* @throws Exception
3030
+ * @deprecated For removal in 7.0. Use {@link #httpBasic(Customizer)} instead
2982
3031
*/
3032
+ @ Deprecated (since = "6.1" , forRemoval = true )
2983
3033
public HttpBasicConfigurer <HttpSecurity > httpBasic () throws Exception {
2984
3034
return getOrApply (new HttpBasicConfigurer <>());
2985
3035
}
@@ -3308,7 +3358,9 @@ public HttpSecurity addFilterAt(Filter filter, Class<? extends Filter> atFilter)
3308
3358
* }
3309
3359
* </pre>
3310
3360
* @return the {@link RequestMatcherConfigurer} for further customizations
3361
+ * @deprecated For removal in 7.0. Use {@link #securityMatchers(Customizer)} instead
3311
3362
*/
3363
+ @ Deprecated (since = "6.1" , forRemoval = true )
3312
3364
public RequestMatcherConfigurer securityMatchers () {
3313
3365
return this .requestMatcherConfigurer ;
3314
3366
}
@@ -3566,7 +3618,28 @@ private void setMatchers(List<? extends RequestMatcher> requestMatchers) {
3566
3618
/**
3567
3619
* Return the {@link HttpSecurity} for further customizations
3568
3620
* @return the {@link HttpSecurity} for further customizations
3621
+ * @deprecated Use the lambda based configuration instead. For example: <pre>
3622
+ * @Configuration
3623
+ * @EnableWebSecurity
3624
+ * public class SecurityConfig {
3625
+ *
3626
+ * @Bean
3627
+ * public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
3628
+ * http
3629
+ * .securityMatchers((matchers) -> matchers
3630
+ * .requestMatchers("/api/**")
3631
+ * )
3632
+ * .authorizeHttpRequests((authorize) -> authorize
3633
+ * .anyRequest().hasRole("USER")
3634
+ * )
3635
+ * .httpBasic(Customizer.withDefaults());
3636
+ * return http.build();
3637
+ * }
3638
+ *
3639
+ * }
3640
+ * </pre>
3569
3641
*/
3642
+ @ Deprecated (since = "6.1" , forRemoval = true )
3570
3643
public HttpSecurity and () {
3571
3644
return HttpSecurity .this ;
3572
3645
}
0 commit comments