Skip to content

Commit a439bc6

Browse files
ngocnhan-tran1996jzheaux
authored andcommitted
Remove EnableWebMvcSecurity
Closes gh-17294 Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
1 parent 19e88f5 commit a439bc6

File tree

4 files changed

+3
-75
lines changed

4 files changed

+3
-75
lines changed

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/EnableGlobalAuthentication.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
2727
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
2828
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
29-
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
3029

3130
/**
3231
* The {@link EnableGlobalAuthentication} annotation signals that the annotated class can
@@ -87,14 +86,12 @@
8786
*
8887
* <ul>
8988
* <li>{@link EnableWebSecurity}</li>
90-
* <li>{@link EnableWebMvcSecurity}</li>
9189
* <li>{@link EnableGlobalMethodSecurity}</li>
9290
* </ul>
9391
*
9492
* Configuring {@link AuthenticationManagerBuilder} in a class without the
9593
* {@link EnableGlobalAuthentication} annotation has unpredictable results.
9694
*
97-
* @see EnableWebMvcSecurity
9895
* @see EnableWebSecurity
9996
* @see EnableGlobalMethodSecurity
10097
* @author Rob Winch

config/src/main/java/org/springframework/security/config/annotation/web/servlet/configuration/EnableWebMvcSecurity.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration;
4949
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
5050
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
51-
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
5251
import org.springframework.security.config.test.SpringTestContext;
5352
import org.springframework.security.config.test.SpringTestContextExtension;
5453
import org.springframework.security.config.users.AuthenticationTestConfiguration;
@@ -110,17 +109,6 @@ public void orderingAutowiredOnEnableWebSecurity() {
110109
this.service.run();
111110
}
112111

113-
@Test
114-
public void orderingAutowiredOnEnableWebMvcSecurity() {
115-
this.spring
116-
.register(AuthenticationTestConfiguration.class, WebMvcSecurityConfig.class,
117-
GlobalMethodSecurityAutowiredConfig.class, ServicesConfig.class)
118-
.autowire();
119-
SecurityContextHolder.getContext()
120-
.setAuthentication(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
121-
this.service.run();
122-
}
123-
124112
@Test
125113
public void getAuthenticationManagerWhenNoAuthenticationThenNull() throws Exception {
126114
this.spring.register(AuthenticationConfiguration.class, ObjectPostProcessorConfiguration.class).autowire();
@@ -358,12 +346,6 @@ static class WebSecurityConfig {
358346

359347
}
360348

361-
@Configuration
362-
@EnableWebMvcSecurity
363-
static class WebMvcSecurityConfig {
364-
365-
}
366-
367349
@Configuration
368350
static class NoOpGlobalAuthenticationConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
369351

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44
Spring Security provides a number of optional integrations with Spring MVC.
55
This section covers the integration in further detail.
66

7-
[[mvc-enablewebmvcsecurity]]
8-
== @EnableWebMvcSecurity
9-
10-
[NOTE]
11-
====
12-
As of Spring Security 4.0, `@EnableWebMvcSecurity` is deprecated.
13-
The replacement is `@EnableWebSecurity`, which adds the Spring MVC features, based upon the classpath.
14-
====
7+
[[mvc-enablewebsecurity]]
8+
== @EnableWebSecurity
159

1610
To enable Spring Security integration with Spring MVC, add the `@EnableWebSecurity` annotation to your configuration.
1711

0 commit comments

Comments
 (0)