To disable this behavior, you can add another class that looks like this:
@Configuration @EnableWebMvcSecurity @Profile("!SecurityOn") public class WebSecurityConfigDisable extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/**").permitAll(); } }
Then, when you launch the application, the only time you need to log in is the SecurityOn profile. If you use Maven and Spring Boot, then the enable command will be next.
mvn spring-boot:run -Dspring.profiles.active=SecurityOn
Running without a profile or another profile will disable . This is useful for local development.
I found this to be necessary when using spring-boot-starter-security , because there was a default setting requiring login.
source share