[英]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: localhost:8080 I get redirected to http://localhost:8080/登錄以使用 HAL 瀏覽器導航我的端點,然后我會看到一個屏幕,要求輸入我沒有的用戶和密碼。
登錄 spring 安全的默認憑據是什么?如何更改它們或禁用登錄選項?
這是我正在使用的依賴項:
<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>
這是登錄屏幕:
運行應用程序后查看控制台 output。 如果您沒有運行時異常,那么您應該很容易找到憑據。 默認情況下,用戶名是“user”,密碼總是不同的,因此是從系統生成的。
為了更清楚起見,登錄頁面帶有此依賴項:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
此外,如果您想為憑證設置一些值,則 go 到application.properties文件並添加這兩行:
spring.security.user.name= your_username
spring.security.user.password= your_password
默認用戶名是user
運行應用程序時,可以在控制台中找到密碼。
例子:
Using generated security password: 18ea5687-bc63-4663-9377-e2817c9d2568
如果您想自己設置它們,可以通過覆蓋application.properties
中的默認值來實現:
spring.security.user.name=stack
spring.security.user.password=overflow
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.