Description
Summary
In Spring Security documentation in the hello-web example here:
https://docs.spring.io/spring-security/site/docs/5.1.5.RELEASE/reference/htmlsingle/#hello-web-security-java-configuration
the code is:
@EnableWebSecurity
public class WebSecurityConfig implements WebMvcConfigurer {
This suggests that custom implementation of WebMvcConfigurer
interface is the standard way of Spring Security configuration.
Further down in the documentation usage of WebSecurityConfigurerAdapter
is mentioned and multiple examples of void configure(HttpSecurity http)
customization are given.
This raises confusion about the role of WebMvcConfigurer
in Spring Security and the use cases for WebMvcConfigurer
vs WebSecurityConfigurerAdapter
.
Most likely the intention in the example was:
@EnableWebSecurity
public class WebSecurityConfig implements WebSecurityConfigurerAdapter {
instead of
@EnableWebSecurity
public class WebSecurityConfig implements WebMvcConfigurer {
Version
5.1.5
Sample
Not only I got confused, Stackoverflow discussing the same:
https://stackoverflow.com/questions/53894649/difference-between-webmvcconfigurer-and-websecurityconfigureradapter