登录后的春季重定向

时间:2018-11-12 11:00:02

标签: java spring spring-security saml-2.0

我正在使用像这样配置的Spring SavedRequestAwareAuthenticationSuccessHandler

<bean id="successRedirectHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<property name="defaultTargetUrl" value="/" />
</bean>

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider ref="samlAuthenticationProvider" />
</security:authentication-manager>

<bean id="samlWebSSOProcessingFilter" class="org.springframework.security.saml.SAMLProcessingFilter">
    <property name="authenticationManager" ref="authenticationManager" />
    <property name="authenticationSuccessHandler" ref="successRedirectHandler" />
    <property name="authenticationFailureHandler" ref="failureRedirectHandler" />
</bean>

,它没有按我预期的方式工作(在身份验证之后,->重定向到首先被调用的网站-网址为localhost:8443/myWebApp/getDetail?id=123)。

当我访问必须经过身份验证的网址时,它只会将我重定向到我的登录名(如果有所不同,则为Google SAML),并且在身份验证后,它会调用onAuthenticationSuccess方法,然后该方法应将我重定向到第一个被调用的网址{{ 1}}

我查看并调试了localhost:8443/myWebApp/getDetail?id=123,其中包含SavedRequestAwareAuthenticationSuccessHandler

其中应包含我的请求,但其中不包含可能使我重定向到正确网页的请求。

SavedRequestAwareAuthenticationSuccessHandler包含这部分代码

RequestCache requestCache = new HttpSessionRequestCache()

调用

requestCache.getRequest(request, response) 

并最终返回NULL

到目前为止我已经尝试过的

1)在currentRequest.getSession(false) 设置为true的情况下更改为SimpleUrlAuthenticationSuccessHandler(永久保留重定向)

2)本教程(https://www.baeldung.com/spring_redirect_after_login)-无法使用,因为我没有登录表单,因此我向Google SAML进行了身份验证

0 个答案:

没有答案