Spring Boot – Basic Security Setup

In this post we are going to look at setting up basic security for your Spring Boot app.

Any Spring Boot app should have some kind of security in place as a general best practice, especially while being deployed in a production environment.

That being said it is actually pretty straight forward to setup a basic authentication mechanism using one of Spring Boot’s starter mechanism.


We are going to build on our existing app and add basic security. Add the following to the pom.xml file.


This would basic security to all the end points of this app.

Add the following properties to the application.properties file.


Here we are setting up the user name and password in the properties file itself and enable the basic security.

Now restart the application and try to access any end point and you would get the Authentication Required screen as shown below.


Enter admin, test as the user name and password and you would be prompted to enter the user name and password again. Enter admin, admin as the username and password and you would be able to access the service.

Basic security is now enabled in your Spring Boot app.


Leave a Reply

Your email address will not be published. Required fields are marked *