认证流程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Security的认证流程可以简要描述如下: 1. 当一个请求进入系统时,会经过一个过滤器链,其中包括一个实现了AbstractAuthenticationProcessingFilter的过滤器。 2. 这个过滤器会首先判断请求的URI是否需要认证,如果需要认证,则执行attemptAuthentication方法进行认证。 3. attemptAuthentication方法会调用AuthenticationManager进行认证,AuthenticationManager是一个接口,具体的实现类是ProviderManager。 4. ProviderManager内部包含了一个List<AuthenticationProvider>对象,通过AuthenticationProvider接口的实现类来扩展不同的认证提供者。 5. 在认证过程中,AuthenticationManager会依次调用每个AuthenticationProvider的authenticate方法进行认证。 6. 如果认证成功,会将认证后的Authentication对象存放到SecurityContext中。 7. 如果认证失败,会通过认证失败处理器AuthenticationFailureHandler进行处理。 8. 认证成功后,会执行successfulAuthentication方法,将已认证的Authentication存放到SecurityContext中。 9. 这样,下一个请求进来时,系统就能知道该请求是否已经通过认证。 总结起来,Spring Security的认证流程包括了过滤器链、认证管理器、认证提供者和认证失败处理器等组件,通过这些组件的协作,实现了对请求的认证和授权。\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* *2* [SpringSecurity认证流程分析](https://blog.csdn.net/chisuisi5702/article/details/126281839)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Spring Security认证过程](https://blog.csdn.net/weixin_38927257/article/details/102960752)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值