我有以下多个配置<http.../>
元素(为了通过基本身份验证和用户表单登录单独支持 REST 身份验证):
<security:http auto-config="false" pattern="/service/**" create-session="never"
entry-point-ref="basicAuthenticationEntryPoint" >
<security:intercept-url pattern="/service/**" requires-channel="any" access="ROLE_REST_SERVICE" />
<security:custom-filter position="BASIC_AUTH_FILTER" ref="basicAuthenticationFilter" />
</security:http>
<security:http auto-config="false" pattern="/**"
entry-point-ref="loginUrlAuthenticationEntryPoint" >
<security:logout logout-url="/logout" />
<security:anonymous enabled="false"/>
<security:custom-filter position="FORM_LOGIN_FILTER" ref="usernamePasswordAuthenticationFilter" />
<security:custom-filter position="ANONYMOUS_FILTER" ref="anonymousAuthFilter" />
</security:http>
在需要身份验证的两个过滤器(FORM_LOGIN_FILTER 和 BASIC_AUTH_FILTER)中,我引用了两个不同的身份验证管理器。
但我收到一条错误消息,表明我已经注册了身份验证管理器。
当我事先知道每个过滤器需要哪个身份验证提供程序时,为什么我要使用一个身份验证管理器?
我是否应该不使用身份验证管理器并开始我的AuthenticationProvider
作为一个bean并将其直接传递到过滤器中AuthenticationManager
?
在 Spring Security 3.1 中,您可以拥有多个 http 元素,每个元素都有自己的身份验证管理器。
您唯一需要做的就是添加以下属性authentication-manager-ref="your ref"
到 http 元素。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)