Java Spring安全筛选器具有多个URL截获映射
我遵循本教程: 在Java Spring安全筛选器具有多个URL截获映射,java,spring,spring-security,interceptor,Java,Spring,Spring Security,Interceptor,我遵循本教程: 在spring安全xml中 在web.xml中,我们必须定义实际的过滤器 springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* 所以我不明白,我们将截取映射到两个位置的两个URL。到/welcome*和/*。为什么我们需要这两个?我在这里遗漏了什么吗?DelegatingFilterProxy不是Spring安
spring安全xml中
在web.xml中,我们必须定义实际的过滤器
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
所以我不明白,我们将截取映射到两个位置的两个URL。到/welcome*
和/*
。为什么我们需要这两个?我在这里遗漏了什么吗?DelegatingFilterProxy
不是Spring安全类。它来自SpringWeb包
标准Servlet 2.3筛选器的代理,委托给
实现过滤器接口的Spring托管bean。支持
web.xml中的“targetBeanName”筛选器init param,指定名称
Spring应用程序上下文中的目标bean
当你使用
<http auto-config="true">
</http>
就像说:
- 所有URL请求(
)都应由Spring Security进行调查/*
- 当URL与
匹配时,主体应具有/welcome*
角色角色\u用户
<!-- Filter Chain -->
<bean id="springSecurityFilterChain"
class="org.springframework.security.web.FilterChainProxy">
<constructor-arg>
<list>
<sec:filter-chain pattern="/favicon.ico"
filters="none"/>
<sec:filter-chain pattern="/img/**"
filters="none"/>
<sec:filter-chain pattern="/**"
filters="bannedIPsFilter, <!-- custom filter -->
channelProcessingFilter,
securityContextPersistenceFilter,
concurrentSessionFilter,
logoutFilter,
secondAuthenticationFilter, <!-- custom filter -->
openIDAuthenticationFilter,
usernamePasswordAuthenticationFilter,
anonymousAuthenticationFilter,
captchaFilter, <!-- custom filter -->
sessionManagementFilter,
exceptionTranslationFilter,
filterSecurityInterceptor,
switchUserProcessingFilter"
/>
</list>
</constructor-arg>
</bean>
springSecurityFilterChain
是此过滤器链中所有spring安全过滤器的外观。它在web.xml中注册为单独的servlet过滤器
/welcome*
-是针对spring安全特定“内部”过滤器的配置,它不存在于web.xml中,servlet容器对此一无所知。回答得很好,很透彻-一定对OP有帮助。谢谢你的好话!回答得很好。当URL匹配多个筛选器链映射时会发生什么情况。第一个是唯一使用的吗?
<!-- Filter Chain -->
<bean id="springSecurityFilterChain"
class="org.springframework.security.web.FilterChainProxy">
<constructor-arg>
<list>
<sec:filter-chain pattern="/favicon.ico"
filters="none"/>
<sec:filter-chain pattern="/img/**"
filters="none"/>
<sec:filter-chain pattern="/**"
filters="bannedIPsFilter, <!-- custom filter -->
channelProcessingFilter,
securityContextPersistenceFilter,
concurrentSessionFilter,
logoutFilter,
secondAuthenticationFilter, <!-- custom filter -->
openIDAuthenticationFilter,
usernamePasswordAuthenticationFilter,
anonymousAuthenticationFilter,
captchaFilter, <!-- custom filter -->
sessionManagementFilter,
exceptionTranslationFilter,
filterSecurityInterceptor,
switchUserProcessingFilter"
/>
</list>
</constructor-arg>
</bean>