2016-09-22 2 views
0

Wicket 1.4에서 Wicket 6.20으로 웹 응용 프로그램을 마이그레이션하는 데 어려움이 있습니다. 스프링 보안을 버전 3.2.8.RELEASE로 이전 버전 (이전 버전)에서 2.0.4로 옮깁니다.SessionManagementFilter가 SessionAuthenticationStrategy를 호출하지 않음

여기 스프링 보안 컨텍스트 구성의 사본이다 동시 로그인이 사용자에게 허용되는지

<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy"> 
    <security:filter-chain-map path-type="ant" > 
     <security:filter-chain request-matcher-ref="requestMatcher" 
       filters=" 
     securityContextPersistenceFilter, 
     concurrentSessionFilter,sessionManagementFilter" 
       pattern="/**" /> 
    </security:filter-chain-map> 
</bean> 

<beans:bean id="securityContextPersistenceFilter" 
    class="org.springframework.security.web.context.SecurityContextPersistenceFilter"> 
    <beans:constructor-arg ref="securityContextRepository"></beans:constructor-arg> 
</beans:bean> 

<beans:bean id="sessionManagementFilter" 
    class="org.springframework.security.web.session.SessionManagementFilter"> 
    <beans:constructor-arg ref="securityContextRepository"></beans:constructor-arg> 
    <beans:constructor-arg ref="sas"></beans:constructor-arg> 
</beans:bean> 

<beans:bean id="requestMatcher" class="org.springframework.security.web.util.matcher.AntPathRequestMatcher" > 
    <beans:constructor-arg value="/**"></beans:constructor-arg> 
</beans:bean> 

<beans:bean id="concurrentSessionFilter" 
    class="org.springframework.security.web.session.ConcurrentSessionFilter"> 
    <beans:constructor-arg ref="sessionRegistry" ></beans:constructor-arg> 
    <beans:constructor-arg value="/petrol/login" ></beans:constructor-arg> 
</beans:bean> 

<beans:bean id="sas" class="org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy"> 
    <beans:constructor-arg> 
    <beans:list> 
     <beans:bean class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy"> 
     <beans:constructor-arg ref="sessionRegistry"/> 
     <beans:property name="maximumSessions" value="1" /> 
     <beans:property name="exceptionIfMaximumExceeded" value="true" /> 
     </beans:bean> 
     <beans:bean class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy"> 
     </beans:bean> 
     <beans:bean class="org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy"> 
     <beans:constructor-arg ref="sessionRegistry"/> 
     </beans:bean> 
    </beans:list> 
    </beans:constructor-arg> 
</beans:bean> 

<beans:bean id="sessionRegistry" 
    class="org.springframework.security.core.session.SessionRegistryImpl" /> 

<beans:bean id="authenticationManager" 
    class="org.springframework.security.authentication.ProviderManager"> 
    <beans:property name="providers"> 
     <beans:list> 
      <beans:ref local="petrolAuthenticationProvider" /> 
     </beans:list> 
    </beans:property> 
</beans:bean> 

<beans:bean name='securityContextRepository' 
    class='org.springframework.security.web.context.HttpSessionSecurityContextRepository'> 
    <beans:property name='allowSessionCreation' value='true' /> 
</beans:bean> 

<beans:bean id="petrolAuthenticationProvider" 
    class="it.loginet.petrol.infrastructure.security.PetrolAuthenticationProvider"> 
    <beans:property name="utenteRepository" ref="utenteRepository" /> 
</beans:bean> 

SessionManagementFilter 우리 관련 테스트를 필터링한다. 성공적인 인증을 확인할 때 SecurityContextRepository에 SecurityContext가 이미 포함되어 있고 "SessionAuthenticationStrategy.onAuthentication"메서드가 호출되지 않는 것이 문제입니다.

 if (!securityContextRepository.containsContext(request)) { 
     Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 

     if (authentication != null && !trustResolver.isAnonymous(authentication)) { 
     // The user has been authenticated during the current request, so call the session strategy 
      try { 
       sessionAuthenticationStrategy.onAuthentication(authentication, request, response); 
      } catch (SessionAuthenticationException e) { 
       // The session strategy can reject the authentication 
       logger.debug("SessionAuthenticationStrategy rejected the authentication object", e); 
       SecurityContextHolder.clearContext(); 
       failureHandler.onAuthenticationFailure(request, response, e); 

       return; 
      } 
......... 

SaveToSessionResponseWrapper 클래스의 HttpSession에 SPRING_SECURITY_KEY 속성 저장의 SessionManagementFilter 이미의 HttpSession에이 속성을 찾아 실제로 내부 SessionAuthenticationStrategy 유효성 검사를 건너 뛰십시오.

내가 이전에 잘못하고있는 것은 무엇입니까?

답변

2

OK, 나는 여기 (http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#ftn.d5e3442) 명시된 바와 같이 내가 내 응용 프로그램에서 사용 된 같은 형태의 로그인 인증을 인식하지 못하는, 내 문제에 대한 해결책 ..

SessionManagementFilter을 찾은 것 같아요. 호출되지 않을 것이다이 필터 내부 따라서 동시성 전략 ..

그래서 이너 AuthenticationManager 사용)의 초기 인증 처리를 제 1 적용 ProviderManager.authenticate() 방법을 대체하는 새로운 SessionManagementProviderManager 인스턴스의 ProviderManager 클래스를 확장하기로, 2) 생성에 SessionAuthenticationStrategy.onAuthentication() 포인트 1에서 인증이 리턴 됨).

아마도이 답변은 스프링 보안 마이그레이션과 동일한 문제를 가진 다른 사람을 도울 수 있습니다.