2014-06-23 2 views
0

우리는 애플리케이션에 Spring 보안을 구현하려고합니다. RememberMeAuthenticationFilter를 확장하고 있습니다. 그러나 문제는 응용 프로그램 컨트롤러가 RememberMeAuthenticationFilter 전에 호출되고 있다는 것입니다. 어쨌든 응용 프로그램 컨트롤러 전에 RememberMeAuthenticationFilter를 호출하도록 할 것입니까? 다음은 저의 구성입니다. 디버그 모드에서 필자는 FilterChainProxy.VirtualFilterChain에 원본 필터와 추가 필터라는 두 세트의 필터가 있음을 알 수있었습니다. 원래 필터에는 springSecurityFilterChain이 있지만 사용자 정의 RememberMeAuthenticationFilter를 호출하지 않습니다. 그리고 추가 필터에는 RememberMeAuthenticationFilter가 있습니다. 컨트롤러가 원래 필터의 끝에 DispatcherServlet을 통해 호출됩니다.사용자 정의 RememberMeAuthenticationFilter 전에 호출되는 애플리케이션 컨트롤러

의 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> 

봄 보안-context.xml에

<http use-expressions="true" auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint" create-session="ifRequired" > 
<long list of intercept-url here> 
    <intercept-url pattern="/**" access="permitAll" requires-channel="any"/> 



    <custom-filter ref="rememberMeProcessingFilter" position="REMEMBER_ME_FILTER" /> 
     <custom-filter ref="authenticationProcessingFilter" position="FORM_LOGIN_FILTER" /> 


</http> 



<beans:bean id="rememberMeProcessingFilter" class="uk.co.and.dealofday.security.SecurityRememberMeAuthenticationFilter"> 
    <beans:property name="authenticationManager" ref="authenticationManager" /> 
    <beans:property name="rememberMeServices" ref="rememberMeServices" /> 
</beans:bean> 



<beans:bean id="authenticationProcessingFilter" class="uk.co.and.dealofday.security.SecurityUsernamePasswordAuthenticationFilter"> 
    <beans:property name="authenticationManager" ref="authenticationManager" /> 
    <beans:property name="rememberMeServices" ref="rememberMeServices" /> 
    <beans:property name="userService" ref="userService"/> 
    <beans:property name="securityHelper" ref="securityHelper" /> 
</beans:bean> 
+0

후 사용자 정의 remember 필터를 선언 그리고 그것은 때문에 호출 할 필요가? 보안 URL (''요소 없음)이 없으므로 필터는 실행되지 않습니다. –

+0

intercept-url의 긴 목록이 있습니다. 방금 그 부분을 건너 뛰었습니다. \t \t <액세스 거부 처리기 REF = "exceptionResolver"/> \t \t \t <차단 - URL 패턴 = "/ 지불/결정/*"액세스 = "permitAll는"필요 채널 = "$ {configurationBean .springSecurityChannel} "// \t

+0

처음에는 언급하지 않았습니다. 필터는 항상 서블릿 (따라서 컨트롤러)보다 먼저 실행되어야합니다. 그렇지 않으면 어딘가에 구성에 문제가 있습니다. –

답변

-1

사용자 정의 authentication 필터

<custom-filter ref="authenticationProcessingFilter" position="FORM_LOGIN_FILTER" /> 
<custom-filter ref="rememberMeProcessingFilter" position="REMEMBER_ME_FILTER" /> 
관련 문제