Conditionally Disabling or Overriding Spring Boot Security Auto-Configuration.

Ravinder Thirumala
2 min readMar 26, 2021

In this article, we’ll have a look at how to disable Security in Spring Boot application and how to customize Security Configuration. For better understanding, first we need to learn how to enable Auto-Configure of Security in the Spring Boot application

Spring Boot Security Auto-Configuration

In order to add security to our Spring Boot application, we need to add the security starter dependency, with gradle we can do that by adding

uber(“org.springframework.boot:spring-boot-starter-security”)

You can find more on this from spring documentation.

Once starter-security is on the classpath, It will include SecurityAutoConfiguration class containing default security configuration. Which means Spring Boot application automatically secures all HTTP endpoints with “basic” authentication.

Conditionally Disabling Spring Boot Security.

If you are planning to have your own Custom Security configuration for your Springboot application , here are some of the ways to do.

Option 1 :

First we will exclude spring security Auto-configuration and then control enable/disable security using config parameter.

To disable Security Auto-Configuration and add our own configuration, we need to exclude the…

--

--