时光老去我们也不散去 2017-08-16 03:15 采纳率: 50%
浏览 3557

CAS服务端登陆成功,不能返回目标页面

输入网址 http://fighting.com:8080/loginPlatformClient
跳转到https://fighting.com:8443/cas/login?service=http%3A%2F%2Ffighting.com%3A8080%2FloginPlatformClient%2Fj_spring_cas_security_check输入账户和密码登陆成功 却跳转到 http://fighting.com:8080/loginPlatformClient/页面这是为什么?

如果输入网址http://fighting.com:8080/loginPlatformClient/indexUser.jsp
跳转到https://fighting.com:8443/cas/login?service=http%3A%2F%2Ffighting.com%3A8080%2FloginPlatformClient%2Fj_spring_cas_security_check输入用户名 密码后http://fighting.com:8080/loginPlatformClient/这是为什么?
配置如下:
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd">

<http auto-config="false" use-expressions="false" entry-point-ref="authEntryPoint" disable-url-rewriting="false">
    <intercept-url pattern="/indexAdmin.jsp" access="ROLE_ADMIN" />
    <intercept-url pattern="/indexUser.jsp" access="ROLE_USER" />
    <intercept-url pattern="/indexSecurity.jsp" access="ROLE_SECURITY" />
    <intercept-url pattern="/indexAuditor.jsp" access="ROLE_AUDITOR" />
    <intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" />   

    <!-- 登出配置 -->  
    <logout logout-url="/j_spring_security_logout" logout-success-url="/login.jsp" delete-cookies="JSESSIONID"/>  

    <!-- 登出Cas Server的过滤器 -->
    <custom-filter ref="requestCasLogoutFilter" before="LOGOUT_FILTER"/>
    <!-- 登出Spring Security的过滤器 -->
    <custom-filter ref="casLogoutFilter" before="CAS_FILTER"/> 
    <custom-filter ref="casFilter" position="CAS_FILTER"/>
    <!-- 添加自己定义的AuthenticationFilter到FilterChain的FORM_LOGIN_FILTER位置 -->
    <custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/> 
</http>

 <beans:bean id="requestCasLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
   <!-- 指定登出成功后需要跳转的地址,这里指向Cas Server的登出URL,以实现单点登出 -->
   <beans:constructor-arg value="https://fighting.com:8443/cas/logout"/>
   <beans:constructor-arg>
      <beans:bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
   </beans:constructor-arg>
   <!-- 该Filter需要处理的地址,默认是Spring Security的默认登出地址“/j_spring_security_logout” -->
   <beans:property name="filterProcessesUrl" value="/j_spring_cas_security_logout"/>
</beans:bean>

<beans:bean id="casLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/> 

<beans:bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
   <beans:property name="authenticationManager" ref="authenticationManager" /> 
</beans:bean>


<!-- AuthenticationEntryPoint,引导用户进行登录 -->
<beans:bean id="authEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
   <beans:property name="loginUrl" value="https://fighting.com:8443/cas/login"/><!-- Cas Server的登录地址 -->
   <beans:property name="serviceProperties" ref="serviceProperties" /><!-- service相关的属性 -->
</beans:bean>

<!-- 指定service相关信息 -->
<beans:bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
    <!-- Cas Server认证成功后的跳转地址,这里要跳转到我们的Spring Security应用,之后会由CasAuthenticationFilter处理,默认处理地址为/j_spring_cas_security_check -->
    <beans:property name="service" value="http://fighting.com:8080/loginPlatformClient/j_spring_cas_security_check" />
    <beans:property name="sendRenew" value="false"/>  
</beans:bean>

<!-- 认证过滤器 -->
<beans:bean id="authenticationFilter"
     class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter" >

    <!-- 登录提交处理  --> 
    <beans:property name="filterProcessesUrl" value="/j_spring_security_check"></beans:property>

    <!-- 登录成功跳转   -->
    <beans:property name="authenticationSuccessHandler" ref="authenticationDispatcher"></beans:property> 

    <!-- 设置登录失败的网址   -->
    <beans:property name="authenticationFailureHandler" ref="simpleUrlAuthenticationFailureHandler"></beans:property>  

    <!-- 用户拥有权限 -->  
    <beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>

<beans:bean id="simpleUrlAuthenticationFailureHandler"  
    class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">  
    <beans:property name="defaultFailureUrl" value="/login.jsp?error=true"></beans:property> 
</beans:bean>

<authentication-manager alias="authenticationManager">
<!-- 使用自定义的重写的MyUserService类来实现从数据库中读取账户密码和权限,并在提交表单的过程中使用md5进行加密后再发送post请求到j_spring_security_check进行登录验证 -->
    <authentication-provider user-service-ref="MyUserService">       
        <password-encoder hash="md5" ref="passwordEncoder">  
        </password-encoder>   
    </authentication-provider> 
    <authentication-provider ref="casAuthenticationProvider"/> 
</authentication-manager>

<beans:bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
  <!-- 通过username来加载UserDetails -->
  <beans:property name="authenticationUserDetailsService">
     <beans:bean class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
        <!-- 真正加载UserDetails的UserDetailsService实现 -->
        <beans:constructor-arg ref="userDetailsManager" />
     </beans:bean>
  </beans:property>
  <beans:property name="serviceProperties" ref="serviceProperties" />
  <!-- 配置TicketValidator在登录认证成功后验证ticket -->
  <beans:property name="ticketValidator">
     <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
        <!-- Cas Server访问地址的前缀,即根路径-->
        <beans:constructor-arg index="0" value="https://fighting.com:8443/cas" />
     </beans:bean>
  </beans:property>
  <beans:property name="key" value="key4CasAuthenticationProvider" />

/beans:bean

<!-- 认证成功的处理类 -->
<beans:bean id="authenticationDispatcher" class="com.potevio.serivce.MyAuthenticationSuccessHandler">  
      <beans:property name="authDispatcherMap">  
        <beans:ref bean="dispatcherMap"/>  
      </beans:property>  
</beans:bean>  
<beans:bean id="dispatcherMap" class="java.util.HashMap">  
     <beans:constructor-arg>  
         <beans:map>  
             <beans:entry key="ROLE_ADMIN" value="/indexAdmin.jsp"/>  
             <beans:entry key="ROLE_USER" value="/indexUser.jsp"/>
             <beans:entry key="ROLE_SECURITY" value="/indexSecurity.jsp"/>
             <beans:entry key="ROLE_AUDITOR" value="/indexAuditor.jsp"/>                   
         </beans:map>  
    </beans:constructor-arg>  
</beans:bean> 

<beans:bean id="userDetailsManager" class="com.potevio.serivce.UserDetailsManager"/>

<beans:bean id="MyUserService" class="com.potevio.serivce.MyUserService">  
</beans:bean>    

<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder">  
</beans:bean>    

<!-- 用于使用eID登录后再登录系统的手动认证过程,读取bean MyUserService,构建 UserDetails -->
<!-- <beans:bean id="SpringContextUtil " class="com.potevio.common.utils.SpringContextUtil ">
</beans:bean> -->

/beans:beans

  • 写回答

1条回答 默认 最新

  • 关注

    我需要当我输入 http://fighting.com:8080/loginPlatformClient 跳转到服务端输入用户名账号登陆成功后跳转到。login.jsp页面,
    如果成功跳转url是否携带ticket

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大