我有一个奇怪的问题。我使用authenticationSuccessHandler创建了casAuthenticationFilter。一切正常。看看我的代码:
<beans:bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter" >
<beans:property name="authenticationManager" ref="authenticationManager" />
<!-- Propiedad añadida para el redireccionamiento a AMS1.1 -->
<beans:property name="authenticationSuccessHandler">
<beans:bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="http://192.168.1.32:8080/AMS1.1/"/>
</beans:bean>
</beans:property>
</beans:bean>
<http auto-config="true" use-expressions="true" access-denied-page="/forbidden.xhtml" entry-point-ref="casAuthEntryPoint">
<intercept-url pattern="/parameters.xhtml" access="hasRole('SES_ADMIN')" />
<intercept-url pattern="/*" access="hasRole('SES_USER')" />
<custom-filter ref="casAuthenticationFilter" position="CAS_FILTER" />
<!--<logout invalidate-session="true" logout-url="/logout" logout-success-url="/cas/logout"/>-->
<custom-filter ref="casSingleSignOutFilter" after="LOGOUT_FILTER"/>
</http>
但这是抓住了。每当我通过localhost登录时:8080 / logingpage /将我重定向到http://192.168.1.32:8080/AMS1.1/。这就是我想要的。但每当我通过MyIp登录时,例如192.168.1.2/logingpage/将我重定向到我输入的页面。例如,当我进入一个页面192.168.1.2:8080/somepage将我重定向到192.168.2:8080 / logingpage,当登录成功时,我将我重定向到192.168.1.2:8080/somepage,这就是我所不知道的事情。我希望我想将我重定向到http://192.168.1.32:8080/AMS1.1/。但是当我使用localhost而不是我目前的Ip时,一切正常。我错过了什么吗?
我的本地IP是192.168.1.32。
答案 0 :(得分:0)
从SavedRequestAwareAuthenticationSuccessHandler API doc开始,您可以将alwaysUseDefaultTargetUrl
设置为true
来实现此目的。
如果
alwaysUseDefaultTargetUrl
属性设置为true,则defaultTargetUrl
将用于目标。存储在会话中的任何DefaultSavedRequest
都将被删除。