Spring 安全和 Cas 日志重定向
Spring Secuirty and Cas logging redirecting
我有一个奇怪的问题。我使用 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/. Thats what I want. But whenever I Log in via MyIp example 192.168.1.2/logingpage/ redirect me to page I enter. Example, wheneever I enter a page 192.168.1.2:8080/somepage redirects me to 192.168.2:8080/logingpage and when loging succes redirects me to 192.168.1.2:8080/somepage and that's what I don't want I want to redirect me to http://192.168.1.32:8080/AMS1.1/。但是当我使用 localhost 而不是我当前的 Ip 时,一切正常。我错过了什么吗?
我的本地ip是192.168.1.32。
从 SavedRequestAwareAuthenticationSuccessHandler API doc 开始,您可以通过将 alwaysUseDefaultTargetUrl
设置为 true
来实现。
If the alwaysUseDefaultTargetUrl
property is set to true, the defaultTargetUrl
will be used for the destination. Any DefaultSavedRequest
stored in the session will be removed.
我有一个奇怪的问题。我使用 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/. Thats what I want. But whenever I Log in via MyIp example 192.168.1.2/logingpage/ redirect me to page I enter. Example, wheneever I enter a page 192.168.1.2:8080/somepage redirects me to 192.168.2:8080/logingpage and when loging succes redirects me to 192.168.1.2:8080/somepage and that's what I don't want I want to redirect me to http://192.168.1.32:8080/AMS1.1/。但是当我使用 localhost 而不是我当前的 Ip 时,一切正常。我错过了什么吗?
我的本地ip是192.168.1.32。
从 SavedRequestAwareAuthenticationSuccessHandler API doc 开始,您可以通过将 alwaysUseDefaultTargetUrl
设置为 true
来实现。
If the
alwaysUseDefaultTargetUrl
property is set to true, thedefaultTargetUrl
will be used for the destination. AnyDefaultSavedRequest
stored in the session will be removed.