@@ -285,8 +285,10 @@ private ApplicationContext getContext() {
285285 * </pre>
286286 * @return the {@link HeadersConfigurer} for further customizations
287287 * @throws Exception
288+ * @deprecated For removal in 7.0. Use {@link #headers(Customizer)} instead
288289 * @see HeadersConfigurer
289290 */
291+ @ Deprecated (since = "6.1" , forRemoval = true )
290292 public HeadersConfigurer <HttpSecurity > headers () throws Exception {
291293 return getOrApply (new HeadersConfigurer <>());
292294 }
@@ -399,7 +401,9 @@ public HttpSecurity headers(Customizer<HeadersConfigurer<HttpSecurity>> headersC
399401 * on the classpath a {@link HandlerMappingIntrospector} is used.
400402 * @return the {@link CorsConfigurer} for customizations
401403 * @throws Exception
404+ * @deprecated For removal in 7.0. Use {@link #cors(Customizer)} instead
402405 */
406+ @ Deprecated (since = "6.1" , forRemoval = true )
403407 public CorsConfigurer <HttpSecurity > cors () throws Exception {
404408 return getOrApply (new CorsConfigurer <>());
405409 }
@@ -486,7 +490,9 @@ public HttpSecurity cors(Customizer<CorsConfigurer<HttpSecurity>> corsCustomizer
486490 * could return true.
487491 * @return the {@link SessionManagementConfigurer} for further customizations
488492 * @throws Exception
493+ * @deprecated For removal in 7.0. Use {@link #sessionManagement(Customizer)} instead
489494 */
495+ @ Deprecated (since = "6.1" , forRemoval = true )
490496 public SessionManagementConfigurer <HttpSecurity > sessionManagement () throws Exception {
491497 return getOrApply (new SessionManagementConfigurer <>());
492498 }
@@ -608,8 +614,10 @@ public HttpSecurity sessionManagement(
608614 * </pre>
609615 * @return the {@link PortMapperConfigurer} for further customizations
610616 * @throws Exception
617+ * @deprecated For removal in 7.0. Use {@link #portMapper(Customizer)} instead
611618 * @see #requiresChannel()
612619 */
620+ @ Deprecated (since = "6.1" , forRemoval = true )
613621 public PortMapperConfigurer <HttpSecurity > portMapper () throws Exception {
614622 return getOrApply (new PortMapperConfigurer <>());
615623 }
@@ -739,7 +747,9 @@ public HttpSecurity portMapper(Customizer<PortMapperConfigurer<HttpSecurity>> po
739747 * Servlet Container's documentation.
740748 * @return the {@link JeeConfigurer} for further customizations
741749 * @throws Exception
750+ * @deprecated For removal in 7.0. Use {@link #jee(Customizer)} instead
742751 */
752+ @ Deprecated (since = "6.1" , forRemoval = true )
743753 public JeeConfigurer <HttpSecurity > jee () throws Exception {
744754 return getOrApply (new JeeConfigurer <>());
745755 }
@@ -850,7 +860,9 @@ public HttpSecurity jee(Customizer<JeeConfigurer<HttpSecurity>> jeeCustomizer) t
850860 * </pre>
851861 * @return the {@link X509Configurer} for further customizations
852862 * @throws Exception
863+ * @deprecated For removal in 7.0. Use {@link #x509(Customizer)} instead
853864 */
865+ @ Deprecated (since = "6.1" , forRemoval = true )
854866 public X509Configurer <HttpSecurity > x509 () throws Exception {
855867 return getOrApply (new X509Configurer <>());
856868 }
@@ -928,7 +940,9 @@ public HttpSecurity x509(Customizer<X509Configurer<HttpSecurity>> x509Customizer
928940 * </pre>
929941 * @return the {@link RememberMeConfigurer} for further customizations
930942 * @throws Exception
943+ * @deprecated For removal in 7.0. Use {@link #rememberMe(Customizer)} instead
931944 */
945+ @ Deprecated (since = "6.1" , forRemoval = true )
932946 public RememberMeConfigurer <HttpSecurity > rememberMe () throws Exception {
933947 return getOrApply (new RememberMeConfigurer <>());
934948 }
@@ -1072,7 +1086,7 @@ public HttpSecurity rememberMe(Customizer<RememberMeConfigurer<HttpSecurity>> re
10721086 * </pre>
10731087 * @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations
10741088 * @throws Exception
1075- * @deprecated Use {@link #authorizeHttpRequests()} instead
1089+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests()} instead
10761090 */
10771091 @ Deprecated
10781092 public ExpressionUrlAuthorizationConfigurer <HttpSecurity >.ExpressionInterceptUrlRegistry authorizeRequests ()
@@ -1187,7 +1201,7 @@ public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrl
11871201 * for the {@link ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry}
11881202 * @return the {@link HttpSecurity} for further customizations
11891203 * @throws Exception
1190- * @deprecated Use {@link #authorizeHttpRequests} instead
1204+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests} instead
11911205 */
11921206 @ Deprecated
11931207 public HttpSecurity authorizeRequests (
@@ -1302,7 +1316,10 @@ public HttpSecurity authorizeRequests(
13021316 * @return the {@link HttpSecurity} for further customizations
13031317 * @throws Exception
13041318 * @since 5.6
1319+ * @deprecated For removal in 7.0. Use {@link #authorizeHttpRequests(Customizer)}
1320+ * instead
13051321 */
1322+ @ Deprecated (since = "6.1" , forRemoval = true )
13061323 public AuthorizeHttpRequestsConfigurer <HttpSecurity >.AuthorizationManagerRequestMatcherRegistry authorizeHttpRequests ()
13071324 throws Exception {
13081325 ApplicationContext context = getContext ();
@@ -1434,7 +1451,9 @@ public HttpSecurity authorizeHttpRequests(
14341451 * when using {@link EnableWebSecurity}.
14351452 * @return the {@link RequestCacheConfigurer} for further customizations
14361453 * @throws Exception
1454+ * @deprecated For removal in 7.0. Use {@link #requestCache(Customizer)} instead
14371455 */
1456+ @ Deprecated (since = "6.1" , forRemoval = true )
14381457 public RequestCacheConfigurer <HttpSecurity > requestCache () throws Exception {
14391458 return getOrApply (new RequestCacheConfigurer <>());
14401459 }
@@ -1485,7 +1504,9 @@ public HttpSecurity requestCache(Customizer<RequestCacheConfigurer<HttpSecurity>
14851504 * {@link EnableWebSecurity}.
14861505 * @return the {@link ExceptionHandlingConfigurer} for further customizations
14871506 * @throws Exception
1507+ * @deprecated For removal in 7.0. Use {@link #exceptionHandling(Customizer)} instead
14881508 */
1509+ @ Deprecated (since = "6.1" , forRemoval = true )
14891510 public ExceptionHandlingConfigurer <HttpSecurity > exceptionHandling () throws Exception {
14901511 return getOrApply (new ExceptionHandlingConfigurer <>());
14911512 }
@@ -1537,7 +1558,9 @@ public HttpSecurity exceptionHandling(
15371558 * automatically applied when using {@link EnableWebSecurity}.
15381559 * @return the {@link SecurityContextConfigurer} for further customizations
15391560 * @throws Exception
1561+ * @deprecated For removal in 7.0. Use {@link #securityContext(Customizer)} instead
15401562 */
1563+ @ Deprecated (since = "6.1" , forRemoval = true )
15411564 public SecurityContextConfigurer <HttpSecurity > securityContext () throws Exception {
15421565 return getOrApply (new SecurityContextConfigurer <>());
15431566 }
@@ -1582,7 +1605,9 @@ public HttpSecurity securityContext(Customizer<SecurityContextConfigurer<HttpSec
15821605 * {@link EnableWebSecurity}.
15831606 * @return the {@link ServletApiConfigurer} for further customizations
15841607 * @throws Exception
1608+ * @deprecated For removal in 7.0. Use {@link #servletApi(Customizer)} instead
15851609 */
1610+ @ Deprecated (since = "6.1" , forRemoval = true )
15861611 public ServletApiConfigurer <HttpSecurity > servletApi () throws Exception {
15871612 return getOrApply (new ServletApiConfigurer <>());
15881613 }
@@ -1638,7 +1663,9 @@ public HttpSecurity servletApi(Customizer<ServletApiConfigurer<HttpSecurity>> se
16381663 * </pre>
16391664 * @return the {@link CsrfConfigurer} for further customizations
16401665 * @throws Exception
1666+ * @deprecated For removal in 7.0. Use {@link #csrf(Customizer)} instead
16411667 */
1668+ @ Deprecated (since = "6.1" , forRemoval = true )
16421669 public CsrfConfigurer <HttpSecurity > csrf () throws Exception {
16431670 ApplicationContext context = getContext ();
16441671 return getOrApply (new CsrfConfigurer <>(context ));
@@ -1713,7 +1740,9 @@ public HttpSecurity csrf(Customizer<CsrfConfigurer<HttpSecurity>> csrfCustomizer
17131740 * </pre>
17141741 * @return the {@link LogoutConfigurer} for further customizations
17151742 * @throws Exception
1743+ * @deprecated For removal in 7.0. Use {@link #logout(Customizer)} instead
17161744 */
1745+ @ Deprecated (since = "6.1" , forRemoval = true )
17171746 public LogoutConfigurer <HttpSecurity > logout () throws Exception {
17181747 return getOrApply (new LogoutConfigurer <>());
17191748 }
@@ -1852,7 +1881,9 @@ public HttpSecurity logout(Customizer<LogoutConfigurer<HttpSecurity>> logoutCust
18521881 * </pre>
18531882 * @return the {@link AnonymousConfigurer} for further customizations
18541883 * @throws Exception
1884+ * @deprecated For removal in 7.0. Use {@link #anonymous(Customizer)} instead
18551885 */
1886+ @ Deprecated (since = "6.1" , forRemoval = true )
18561887 public AnonymousConfigurer <HttpSecurity > anonymous () throws Exception {
18571888 return getOrApply (new AnonymousConfigurer <>());
18581889 }
@@ -2015,8 +2046,10 @@ public HttpSecurity anonymous(Customizer<AnonymousConfigurer<HttpSecurity>> anon
20152046 * </pre>
20162047 * @return the {@link FormLoginConfigurer} for further customizations
20172048 * @throws Exception
2049+ * @deprecated For removal in 7.0. Use {@link #formLogin(Customizer)} instead
20182050 * @see FormLoginConfigurer#loginPage(String)
20192051 */
2052+ @ Deprecated (since = "6.1" , forRemoval = true )
20202053 public FormLoginConfigurer <HttpSecurity > formLogin () throws Exception {
20212054 return getOrApply (new FormLoginConfigurer <>());
20222055 }
@@ -2191,7 +2224,9 @@ public HttpSecurity formLogin(Customizer<FormLoginConfigurer<HttpSecurity>> form
21912224 * @return the {@link Saml2LoginConfigurer} for further customizations
21922225 * @throws Exception
21932226 * @since 5.2
2227+ * @deprecated For removal in 7.0. Use {@link #saml2Login(Customizer)} instead
21942228 */
2229+ @ Deprecated (since = "6.1" , forRemoval = true )
21952230 public Saml2LoginConfigurer <HttpSecurity > saml2Login () throws Exception {
21962231 return getOrApply (new Saml2LoginConfigurer <>());
21972232 }
@@ -2421,7 +2456,9 @@ public HttpSecurity saml2Logout(Customizer<Saml2LogoutConfigurer<HttpSecurity>>
24212456 * @return the {@link Saml2LoginConfigurer} for further customizations
24222457 * @throws Exception
24232458 * @since 5.6
2459+ * @deprecated For removal in 7.0. Use {@link #saml2Logout(Customizer)} instead
24242460 */
2461+ @ Deprecated (since = "6.1" , forRemoval = true )
24252462 public Saml2LogoutConfigurer <HttpSecurity > saml2Logout () throws Exception {
24262463 return getOrApply (new Saml2LogoutConfigurer <>(getContext ()));
24272464 }
@@ -2517,7 +2554,9 @@ public HttpSecurity saml2Metadata(Customizer<Saml2MetadataConfigurer<HttpSecurit
25172554 * @return the {@link Saml2MetadataConfigurer} for further customizations
25182555 * @throws Exception
25192556 * @since 6.1
2557+ * @deprecated For removal in 7.0. Use {@link #saml2Metadata(Customizer)} instead
25202558 */
2559+ @ Deprecated (since = "6.1" , forRemoval = true )
25212560 public Saml2MetadataConfigurer <HttpSecurity > saml2Metadata () throws Exception {
25222561 return getOrApply (new Saml2MetadataConfigurer <>(getContext ()));
25232562 }
@@ -2608,6 +2647,7 @@ public Saml2MetadataConfigurer<HttpSecurity> saml2Metadata() throws Exception {
26082647 * @return the {@link OAuth2LoginConfigurer} for further customizations
26092648 * @throws Exception
26102649 * @since 5.0
2650+ * @deprecated For removal in 7.0. Use {@link #oauth2Login(Customizer)} instead
26112651 * @see <a target="_blank" href=
26122652 * "https://tools.ietf.org/html/rfc6749#section-4.1">Section 4.1 Authorization Code
26132653 * Grant</a>
@@ -2617,6 +2657,7 @@ public Saml2MetadataConfigurer<HttpSecurity> saml2Metadata() throws Exception {
26172657 * @see org.springframework.security.oauth2.client.registration.ClientRegistration
26182658 * @see org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
26192659 */
2660+ @ Deprecated (since = "6.1" , forRemoval = true )
26202661 public OAuth2LoginConfigurer <HttpSecurity > oauth2Login () throws Exception {
26212662 return getOrApply (new OAuth2LoginConfigurer <>());
26222663 }
@@ -2729,10 +2770,12 @@ public HttpSecurity oauth2Login(Customizer<OAuth2LoginConfigurer<HttpSecurity>>
27292770 * @return the {@link OAuth2ClientConfigurer} for further customizations
27302771 * @throws Exception
27312772 * @since 5.1
2773+ * @deprecated For removal in 7.0. Use {@link #oauth2Client(Customizer)} instead
27322774 * @see <a target="_blank" href=
27332775 * "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
27342776 * Framework</a>
27352777 */
2778+ @ Deprecated (since = "6.1" , forRemoval = true )
27362779 public OAuth2ClientConfigurer <HttpSecurity > oauth2Client () throws Exception {
27372780 OAuth2ClientConfigurer <HttpSecurity > configurer = getOrApply (new OAuth2ClientConfigurer <>());
27382781 this .postProcess (configurer );
@@ -2783,10 +2826,13 @@ public HttpSecurity oauth2Client(Customizer<OAuth2ClientConfigurer<HttpSecurity>
27832826 * @return the {@link OAuth2ResourceServerConfigurer} for further customizations
27842827 * @throws Exception
27852828 * @since 5.1
2829+ * @deprecated For removal in 7.0. Use {@link #oauth2ResourceServer(Customizer)}
2830+ * instead
27862831 * @see <a target="_blank" href=
27872832 * "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
27882833 * Framework</a>
27892834 */
2835+ @ Deprecated (since = "6.1" , forRemoval = true )
27902836 public OAuth2ResourceServerConfigurer <HttpSecurity > oauth2ResourceServer () throws Exception {
27912837 OAuth2ResourceServerConfigurer <HttpSecurity > configurer = getOrApply (
27922838 new OAuth2ResourceServerConfigurer <>(getContext ()));
@@ -2884,7 +2930,9 @@ public HttpSecurity oauth2ResourceServer(
28842930 * </pre>
28852931 * @return the {@link ChannelSecurityConfigurer} for further customizations
28862932 * @throws Exception
2933+ * @deprecated For removal in 7.0. Use {@link #requiresChannel(Customizer)} instead
28872934 */
2935+ @ Deprecated (since = "6.1" , forRemoval = true )
28882936 public ChannelSecurityConfigurer <HttpSecurity >.ChannelRequestMatcherRegistry requiresChannel () throws Exception {
28892937 ApplicationContext context = getContext ();
28902938 return getOrApply (new ChannelSecurityConfigurer <>(context )).getRegistry ();
@@ -2979,7 +3027,9 @@ public HttpSecurity requiresChannel(
29793027 * </pre>
29803028 * @return the {@link HttpBasicConfigurer} for further customizations
29813029 * @throws Exception
3030+ * @deprecated For removal in 7.0. Use {@link #httpBasic(Customizer)} instead
29823031 */
3032+ @ Deprecated (since = "6.1" , forRemoval = true )
29833033 public HttpBasicConfigurer <HttpSecurity > httpBasic () throws Exception {
29843034 return getOrApply (new HttpBasicConfigurer <>());
29853035 }
@@ -3308,7 +3358,9 @@ public HttpSecurity addFilterAt(Filter filter, Class<? extends Filter> atFilter)
33083358 * }
33093359 * </pre>
33103360 * @return the {@link RequestMatcherConfigurer} for further customizations
3361+ * @deprecated For removal in 7.0. Use {@link #securityMatchers(Customizer)} instead
33113362 */
3363+ @ Deprecated (since = "6.1" , forRemoval = true )
33123364 public RequestMatcherConfigurer securityMatchers () {
33133365 return this .requestMatcherConfigurer ;
33143366 }
@@ -3566,7 +3618,28 @@ private void setMatchers(List<? extends RequestMatcher> requestMatchers) {
35663618 /**
35673619 * Return the {@link HttpSecurity} for further customizations
35683620 * @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>
35693641 */
3642+ @ Deprecated (since = "6.1" , forRemoval = true )
35703643 public HttpSecurity and () {
35713644 return HttpSecurity .this ;
35723645 }
0 commit comments