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 –