1.执行 AuthenticationManager 认证方法 authenticate(UsernamePasswordAuthenticationToken)
2.ProviderManager 实现了 authenticate(UsernamePasswordAuthenticationToken)
3.ProviderManager 是通过自身管理的n个AuthenticationProvider认证提供者去进行认证
4.AuthenticationProvider认证提供者 使用自身的authenticate(Authentication)方法;
5.AuthenticationProvider的authenticate(Authentication)方法是被AbstractUserDetailsAuthenticationProvider所实现
6.AbstractUserDetailsAuthenticationProvider 抽象用户细节认证提供者 会调用 自身声明的retrieveUser抽象方法来检索用户
7.retrieveUser抽象方法在DaoAuthenticationProvider 持久层认证提供者 中进行了体现
8.DaoAuthenticationProvider 持久层认证提供者 包含 UserDetailsService 用户细节处理器,
9.用户细节处理器的loadUserByUsername方法又被自定义的UserDetailsServiceImpl所实现
10.UserDetailsServiceImpl实现类取出数据库中的该登录名的数据(selectUserByUserName),并将用户的菜单权限数据和基本信息封装成一个UserDetails用户细节返回!
11.AbstractUserDetailsAuthenticationProvider 抽象用户细节认证提供者 最终获取到UserDeatils
12.然后AbstractUserDetailsAuthenticationProvider 调用additionalAuthenticationChecks方法对用户的密码进行最后的检查
13.密码的校验是由BCryptPasswordEncoder 通过实现PasswordEncoder 的matches方法来完成,
14.BCryptPasswordEncoder .matches 方法会校验密文是否属于自己的编码格式,最终密码校验的细节完全在BCrypt实体类中进行
###BCrypt 如何判断 密码和数据库的密码是否相同的?
首先BCrypt 是从数据库的密码中提取加密的盐值,并校验数据库密码的长度不能小于28和数据库密码的版本(前两个字符必须是"$2")
然后从数据库密码中获取真正的盐值,然后将用户提交的密码结合盐值加密,对比加密后的密码与数据库是否一致
当然特殊情况下你可以在BCrypt 源码的第345行打断点,再直接操作数据库就可以修改密码