我在登录我的应用程序时遇到问题。
我使用 Spring Security 及其formLogin()
和 BCrypt 编码器。
我在 html 中创建注册页面,这很好用。我可以注册并将我的用户保存到我的数据库,但是 当我想登录我的页面时。我不能。我看到了Bad Credentials
,这适用于任何用户。
你可以帮我吗?
https://github.com/Bartosz777/mylibrary <-这是我的github与这个项目。
当我尝试在控制台中登录localhost:8080/login
时,我看到
Hibernate:
select user0_.id as id1_3_, user0_.email as email2_3_,
user0_.is_enabled as is_enabl3_3_, user0_.password as password4_3_,
user0_.role as role5_3_, user0_.username as username6_3_
from user user0_
where user0_.username=?
________________________________________________________________________________
UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE
**2020-06-22 19:28:30.520 DEBUG 16804 --- [nio-8080-exec-3] o.s.s.a.dao.DaoAuthenticationProvider : Authentication failed: password does not match stored value
2020-06-22 19:28:30.521 DEBUG 16804 --- [nio-8080-exec-3] w.a.UsernamePasswordAuthenticationFilter : Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials**
That's I have after logining to my app. Do you know why?
在你WebSecurityConfig
你还必须passwordEncoder
设置为AuthenticationManagerBuild
,像这样:
@Override
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}