6
我試圖在使用CAS和Spring Security的幾個Web應用程序中實現SSO。預期的情況下:
CAS - HTTP://本地主機:8080/CAS/
應用程序的受保護內容 - HTTP://localhost:8081/cas-client1/secure/index.html
應用B保護的內容 - HTTP: //localhost:8081/cas-client2/secure/index.html
使用CAS + Spring Security實現SSO
1)當用戶訪問cas-client1時,會提示CAS登錄表單並觸發認證。
2)相同的用戶訪問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>
很好的瞭解來進行測試,但我想每個人都應該對https- – chrismarx 2011-02-21 20:39:52
運行此謝謝!一年前,我第一次偶然發現了這個答案,並開始再次潛入CAS。另一個可能在QA環境中存在問題的參數是p:cookieDomain。如果生產與QA之間的域名不同,則需要對此設置進行調整或完全刪除。刪除p:cookieDomain並將p:cookieSecure =「false」設置爲在QA中啓動並運行CAS的最寬鬆設置。 – AndreiM 2013-06-03 18:42:19
終於我知道了+1 .. – edaklij 2013-08-02 09:23:30