java – 使用CAS Spring Security实现SSO
发布时间:2020-12-14 05:57:08 所属栏目:Java 来源:网络整理
导读:我正在尝试使用CAS和 Spring Security在多个Web应用程序中实现SSO.预期案例: CAS – http:// localhost:8080 / cas / 应用程序受保护的内容 – http://localhost:8081/cas-client1/secure/index.html 应用B受保护的内容 – http://localhost:8081/cas-c
我正在尝试使用CAS和
Spring Security在多个Web应用程序中实现SSO.预期案例:
CAS – http:// localhost:8080 / cas / 应用程序受保护的内容 – http://localhost:8081/cas-client1/secure/index.html 应用B受保护的内容 – http://localhost:8081/cas-client2/secure/index.html 1)当用户访问cas-client1时,将提示CAS登录表单并触发认证. 但是,我未能执行第2步.CAS登录表单仍然提示用户,因此需要双重登录.我的Spring Security配置中是否有任何错误设置: <security:http entry-point-ref="casAuthenticationEntryPoint" auto-config="true"> <security:intercept-url pattern="/secure/**" access="ROLE_USER" /> <security:custom-filter position="CAS_FILTER" ref="casAuthenticationFilter" /> </security:http> <bean id="casAuthenticationEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"> <property name="loginUrl" value="http://localhost:8080/cas/login" /> <property name="serviceProperties" ref="serviceProperties" /> </bean> <bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"> <!-- http://localhost:8081/cas-client2 for app 2--> <property name="service" value="http://localhost:8081/cas-client1/j_spring_cas_security_check" /> </bean> <security:authentication-manager alias="authenticationManager"> <security:authentication-provider ref="casAuthenticationProvider" /> </security:authentication-manager> <bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"> <property name="authenticationManager" ref="authenticationManager" /> <property name="authenticationFailureHandler"> <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"> <property name="defaultFailureUrl" value="/casfailed.jsp" /> </bean> </property> </bean> <bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> <property name="userDetailsService" ref="userService" /> <property name="serviceProperties" ref="serviceProperties" /> <property name="ticketValidator"> <bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"> <constructor-arg index="0" value="http://localhost:8080/cas" /> </bean> </property> <property name="key" value="an_id_for_this_auth_provider_only" /> </bean> <security:user-service id="userService"> <security:user name="wilson" password="wilson" authorities="ROLE_USER" /> </security:user-service> 解决方法
问题终于解决了.我的CAS使用HTTP,因此需要将安全cookie设置为false.
修改ticketGrantingTicketCookieGenerator.xml p:cookieSecure="false" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |