SpringSecurity用户密码验证过程

SpringSecurity中的UsernamePasswordAuthenticationFilter处理登录密码验证,基于AbstractAuthenticationProcessingFilter和AuthenticationManager。AuthenticationManager的子类ProviderManager遍历AuthenticationProvider,使用DaoAuthenticationProvider进行实际验证,通过AbstractUserDetailsAuthenticationProvider和passwordEncoder对比加密后的密码。用户信息从Spring缓存或数据库加载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SpringSecurity过滤链当中的UsernamePasswordAuthenticationFilter负责登陆密码验证
  • AbstractAuthenticationProcessingFilter是UsernamePasswordAuthenticationFilter的父接口,接口当中就有一个this.getAuthenticationManager()方法,获取AuthenticationManager对象。
  • AuthenticationManager对象当中有一个方法:Authentication authenticate(Authentication authentication) ,传入authentication对象用来密码验证。
  • AuthenticationManager的子类ProviderManager实现了该方法,可能有多种验证方式,因此遍历一个集合,有一个满足就可以,代码如下
@Override
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
   
   
		Class<? extends Authentication> toTest = authentication.getClass();
		//判断使用哪种验证方式
			if (!pro
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值