當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Security——login显示[Bad credentials]
生活随笔
收集整理的這篇文章主要介紹了
Spring Security——login显示[Bad credentials]
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題描述
或者
org.springframework.security.authentication.BadCredentialsException: Bad credentials。?
問題分析
一、username或者password錯誤
默認情況下,不管用戶名不存在,還是密碼錯誤,Spring Security都會報出Bad credentials異常信息,而不現實具體的錯誤。
源碼:
org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider
try { user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication); } catch (UsernameNotFoundException notFound) { logger.debug("User '" + username + "' not found"); if (hideUserNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } }二、訪問權限不夠
三、密碼加密問題
對于密碼加密問題可能是如下情況:
1.密碼無加密,這時應該在密碼前加上 {noop},具體原因請翻閱官方api
User user = new User(userInfo.getUsername(),"{noop}"+ userInfo.getPassword(),getAuthority(userInfo.getRoles()));2.在配置文件中設置了密碼加密卻沒有對其在service中對其應用
3.對比下存入用戶到數據庫時使用的加密算法,和Spring Security中配置的加密算法是否一致。
解決方案
見問題分析。
參考文章
https://blog.csdn.net/qq_37252930/article/details/95723940
https://blog.csdn.net/qq_41950229/article/details/98479327
https://www.cnblogs.com/jifeng/archive/2012/06/09/2542928.html
https://blog.csdn.net/weixin_44580977/article/details/98491875
總結
以上是生活随笔為你收集整理的Spring Security——login显示[Bad credentials]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Visual C++——设置光标Curs
- 下一篇: Windows 10——连接鼠标时触摸板