1
你好,我有一個Spring Boot應用程序,它只有1個Admin和沒有用戶。 我已經創建了一個名爲「administrator」的表,其中包含用戶名和帶有散列密碼的字符串。 (我把密碼轉換器這樣做。)Spring Boot,MySQL:如何用散列密碼進行數據庫驗證?
現在的問題是我應該在WebSecurityConfiguration.java
改變,這樣的代碼跟我已經寫在登錄字符串檢查哈希在我的數據庫形成能夠登錄
我的代碼:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("admin").password("admin").roles("ADMIN");
}
我發現下面的,但我還是真的不知道該怎麼做:
- Switching from MD5 to BCrypt with Spring Security
- http://kielczewski.eu/2014/12/spring-boot-security-application/
- Configuring Spring Boot Security to use BCrypt password encoding in Grails 3.0
你閱讀的文檔? http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc-authentication-jdbc –
我看着它,但它並沒有真正顯示如何進行身份驗證。我讀到我需要編碼結束編碼密碼。但是我不知道我必須做什麼更改,它會編碼我在WebSecurity中定義的密碼,將其保存在數據庫中,並且在嘗試進行身份驗證時可以從數據庫進行編碼。 – PrestigeDev
請參閱http://www.mkyong.com/spring-security/spring-security-form-login-using-database/例如和http://stackoverflow.com/questions/8521251/spring-securitypassword-encoding-in -db-and-in-applicationcontext –