SpringSecurity学习(一)认证流程

本文概述了Spring Security中的Authentication流程,从AbstractAuthenticationProcessingFilter的doFilter方法,到UsernamePasswordAuthenticationFilter的使用,以及DaoAuthenticationProvider的authenticate方法。重点讲解了Authentication对象的认证步骤和关键组件如UsernamePasswordAuthenticationToken和ProviderManager。

目录

基本流程

详细流程

AbstractAuthenticationProcessingFilter

doFilter()

UsernamePasswordAuthenticationFilter

父类调用 attemptAuthentication()

UsernamePasswordAuthenticationToken

ProviderManager

DaoAuthenticationProvider

authenticate()

总结Authentication对象认证流程


此文为本人学习完尚硅谷SpringSecurity之后的笔记,欢迎指出不足之处。

视频链接:https://www.bilibili.com/video/BV15a411A7kP

基本流程

详细流程

AbstractAuthenticationProcessingFilter

doFilter()

UsernamePasswordAuthenticationFilter

父类调用 attemptAuthentication()

UsernamePasswordAuthenticationToken

1.UsernamePasswordAuthenticationToken 是 Authentication 的实现类

 

2.两个构造函数

3.Authentication 接口的实现类用于存储用户认证信息

ProviderManager

为 AuthenticationManager 实现类

 

UsernamePasswordAuthenticationToken 的父类为AbstractAuthenticationToken

DaoAuthenticationProvider

为 AuthenticationProvider 的实现类

authenticate() 为父类中方法

authenticate()

1.调用字类重写的 retrieveUser() 获取UserDetails对象

 

2.调用字类重写的 additionalAuthenticationChecks() 判断传入的 Authentication对象中密码 是否与获取的 UserDetails对象中密码对应 (通过PasswordEncoder对比)

3.匹配成功,组装Authentication对象

4.我们可以实现自己需要的 UserDetailsService 与 UserDetails 以及 PasswordEncoder

 

总结Authentication对象认证流程

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值