Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Spring Security default credentials for Spring Boot?

I am working with Spring Boot and I am using spring-data-rest-hal-browser, everything seems to be fine, except when i try to hit the URL: http://localhost:8080 I get redirected to http://localhost:8080/login to use the HAL browser to navigate my endpoint, then I get a screen requesting for a user and a password that I don't have.

What are the default credentials to login to spring security and how can I change them or disable the login option?

This is the dependency I am using:

<dependency>
 <groupId>org.springframework.data</groupId>
 <artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>

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

And this is the login screen:

enter image description here

like image 988
Israelm Avatar asked Sep 05 '25 03:09

Israelm


2 Answers

Take a look at the console output after running your application. If you have no run-time exceptions, then you should easily find the credentials. By default the username is user and the password is always different and therefore generated from the system.

For more clarity, the login page comes with this dependency:

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

Also, if you want to set some values for the credentials, then go to the application.properties file and add those two lines:

spring.security.user.name=<your/username>
spring.security.user.password=<your/password>
like image 81
xdevx32 Avatar answered Sep 07 '25 21:09

xdevx32


Default username is user

password can be found in the console when you run your application.

example:

Using generated security password: 18ea5687-bc63-4663-9377-e2817c9d2568

If you want to set them yourself you can do so by overriding the defaults in application.properties:

spring.security.user.name=stack
spring.security.user.password=overflow
like image 31
Sayf Avatar answered Sep 07 '25 22:09

Sayf