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:
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With