Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Security-SavedRequestStawareAuthenticationSuccessHandler是否已损坏?_Spring_Spring Security - Fatal编程技术网

Spring Security-SavedRequestStawareAuthenticationSuccessHandler是否已损坏?

Spring Security-SavedRequestStawareAuthenticationSuccessHandler是否已损坏?,spring,spring-security,Spring,Spring Security,TLDR:Spring在重定向到登录页面时正在破坏当前HTTP会话;这将破坏登录后导航到DefaultSavedRequest的功能。为什么会这样 细节- 我正在维护一个旧式Spring应用程序: Spring Core版本3.1.0 Spring安全版本3.1.0 尝试在我的登录配置中使用SavedRequestAwareAuthenticationSuccessHandler时,它不起作用。以下是正在发生的事情: HTTP获取安全资源:http://localhost:8080/mya

TLDR:Spring在重定向到登录页面时正在破坏当前HTTP会话;这将破坏登录后导航到DefaultSavedRequest的功能。为什么会这样

细节- 我正在维护一个旧式Spring应用程序:

  • Spring Core版本3.1.0
  • Spring安全版本3.1.0
尝试在我的登录配置中使用SavedRequestAwareAuthenticationSuccessHandler时,它不起作用。以下是正在发生的事情:

  • HTTP获取安全资源:
    http://localhost:8080/myapp/viewWorkOrder?workOrderNumber=315261
  • Spring正确确定我未登录并保存我的请求:

    DEBUG o.s.s.w.s.HttpSessionRequestCache - DefaultSavedRequest added to Session: DefaultSavedRequest[http://localhost:8080/myapp/viewWorkOrder?workOrderNumber=315261]
    
  • Spring正确重定向到我的登录页面:

    DEBUG o.s.security.web.FilterChainProxy - /login.jsp at position 1 of 9 in additional filter chain; firing Filter: 'ChannelProcessingFilter'
    
  • Spring将销毁当前会话,这将有效地破坏以后使用DefaultSavedRequest的能力:

    DEBUG o.s.s.w.s.HttpSessionEventPublisher - Publishing event: org.springframework.security.web.session.HttpSessionDestroyedEvent[source=org.apache.catalina.session.StandardSessionFacade@b25f027]
    
为什么或是什么导致当前会话被破坏

以下是相关的配置详细信息:

<bean id="savedRequestAwareAuthenticationSuccessHandler"
    class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <property name="defaultTargetUrl" value="/postLogin" />
    <property name="targetUrlParameter" value="targetUrl" />
    <property name="alwaysUseDefaultTargetUrl" value="false" />
</bean>

<security:http auto-config="false">
    <!-- Override default login and logout pages -->
    <security:form-login login-page="/login.jsp"
                         login-processing-url="/j_spring_security_check"
                         authentication-failure-url="/login.jsp?login_error=1"
                         authentication-success-handler-ref="savedRequestAwareAuthenticationSuccessHandler"
                         />

    <security:session-management session-fixation-protection="none"/>

  • 请注意,包含
    会话管理
    似乎不会以任何方式影响该功能

嗯,这很尴尬,但为了在堆栈溢出问题上成为一个好公民,我想我会分享我的发现

在Spring HttpSessionEventPublisher中设置断点以查看堆栈是否可以给我提供线索后,它确实提供了线索。以下是一个屏幕截图:

您会注意到login.jsp在堆栈上。作为这个特定应用程序的新手,我甚至没有真正怀疑JSP,但我发现:


显然,删除这个scriptlet解决了我的问题。现在我只是想知道为什么有人这么做,我在这个过程中破坏了什么:)

你到底什么时候看到你的会话被破坏了?就在重定向之后?或者在您输入凭据并尝试登录之后?@Leffchik,在重定向之后。我将在几分钟内添加另一条注释,因为我试图隔离与重定向控制器相关的事件发生的时间。