此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Security 6.4.1! |
DaoAuthenticationProvider
本节将探讨DaoAuthenticationProvider
在 Spring Security 中工作。
下图说明了AuthenticationManager
在读取用户名和密码部分的数字中。

图 1.
DaoAuthenticationProvider
用法身份验证
Filter
从读取用户名和密码部分传递一个UsernamePasswordAuthenticationToken
到AuthenticationManager
,它由ProviderManager
.
这
ProviderManager
配置为使用 AuthenticationProvider 类型的DaoAuthenticationProvider
.
DaoAuthenticationProvider
查找UserDetails
从UserDetailsService
.
DaoAuthenticationProvider
使用PasswordEncoder
要验证UserDetails
在上一步中返回。
身份验证成功后,
Authentication
返回的 类型为UsernamePasswordAuthenticationToken
并且有一个主体,该主体是UserDetails
由配置的UserDetailsService
.
最终,返回的UsernamePasswordAuthenticationToken
在SecurityContextHolder
通过身份验证Filter
.