spring security原理

本文详细介绍了Spring Security如何通过一系列过滤器实现其功能,包括过滤器的调用顺序及作用,提供了对Spring Security深入理解的指南。

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

spring security通过一系列过滤器实现其功能,入口过滤器如下(web.xml):

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

其他过滤器调用顺序:

 

然后通过org.springframework.security.web.FilterChainProxy过滤器获取以下过滤器列表:

org.springframework.security.web.context.SecurityContextPersistenceFilter@4976abb4

org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@3ea61bd9

org.springframework.security.web.authentication.logout.LogoutFilter@469ddd58

org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@443b70fc

org.springframework.security.web.savedrequest.RequestCacheAwareFilter@386c58c4

org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@361af4c3

org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1ec59845

org.springframework.security.web.session.SessionManagementFilter@1e6a7f1

org.springframework.security.web.access.ExceptionTranslationFilter@5b167571

org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3a4b2e3c

然后由内部类 VirtualFilterChain 依次调用这些过滤器实现其认证、授权等功能 (org.springframework.security.web.FilterChainProxy$VirtualFilterChain)

细节可参考某大牛的文章:

http://dead-knight.iteye.com/category/220917

转载于:https://www.cnblogs.com/SEC-fsq/p/5231224.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值