-
先将用于登录的账号密码存到
UsernamePasswordAuthenticationToken -
执行
AuthenticationManager认证方法authenticate(UsernamePasswordAuthenticationToken) -
ProviderManager实现了AuthenticationManager.authenticate(UsernamePasswordAuthenticationToken) -
ProviderManager是通过自身管理的n个AuthenticationProvider认证提供者去进行认证 -
AuthenticationProvider认证提供者 使用自身的authenticate(Authentication)方法; -
AuthenticationProvider的authenticate(Authentication)方法是被AbstractUserDetailsAuthenticationProvider所实现 -
AbstractUserDetailsAuthenticationProvider抽象用户细节认证提供者 会调用 自身声明的retrieveUser抽象方法来检索用户 -
retrieveUser抽象方法在DaoAuthenticationProvider持久层认证提供者 中进行了体现 -
DaoAuthenticationProvider持久层认证提供者 包含UserDetailsService用户细节处理器, -
用户细节处理器的
loadUserByUsername方法又被自定义的UserDetailsServiceImpl所实现 -
UserDetailsServiceImpl实现类取出数据库中的该登录名的数据(selectUserByUserName),并将用户的菜单权限数据和基本信息封装成一个UserDetails用户细节返回! -
AbstractUserDetailsAuthenticationProvider抽象用户细节认证提供者 最终获取到UserDeatils -
然后
AbstractUserDetailsAuthenticationProvider调用additionalAuthenticationChecks方法对用户的密码进行最后的检查 -
密码的校验是由
BCryptPasswordEncoder通过实现PasswordEncoder的matches方法来完成, -
BCryptPasswordEncoder.matches方法会校验密文是否属于自己的编码格式,最终密码校验的细节完全在BCrypt实体类中进行