Adding security to rest api service built with Spring Boot app

81 Views Asked by At

I have managed to build a rest api using Spring boot actuator & it works well. I need to now add security to the application and found a link which indicated that all that needs to be done, is to add the following to the pom file:

<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-security</artifactId>
</dependency>

I tried that and did not get the expected result which was to see the following in the console;

Using default security password: 7dfsdg4d0-4dfsdfsd93-dsdf9f8-axxe1-xxxxxx

Any suggestions or links to solutions, would be appreciated.

1

There are 1 best solutions below

0
On

I have done this before and it works although I think some versions of Spring Boot have had an issue with this one feature. I was playing with it a little bit and if you copied any of the samples it is possible that you have some other configuration that you have is overriding it. I think this link has good info. Look to ensure you don't have anything in your properties file like "security.user.password" and that you don't have any annotations like @EnableWebSecurity that override any defaults. Let me know if that is helpful and if not maybe you can send a link to GitHub where your code is for someone to take a look.