2010-07-19 24 views
6

Tôi đang cố triển khai SSO trên một số ứng dụng web bằng CAS và Spring Security. Trường hợp dự kiến:
CAS - http: // localhost: 8080/cas/
Ứng dụng Nội dung được bảo vệ - http: //localhost:8081/cas-client1/secure/index.html
Nội dung được bảo vệ ứng dụng B - http: //localhost:8081/cas-client2/secure/index.html
Thực hiện SSO bằng cách sử dụng CAS + Bảo mật mùa xuân

1) Khi người dùng truy cập vào cas-client1, biểu mẫu đăng nhập CAS sẽ được nhắc và kích hoạt xác thực.
2) truy cập cùng một người dùng cas-client2, đăng nhập trước đó nên được công nhận và không có hình thức đăng nhập sẽ được nhắc

Tuy nhiên, tôi đang thất bại trong việc thực hiện các bước mẫu đăng nhập 2. CAS vẫn nhắc người dùng và do đó đòi hỏi đôi đăng nhập. Có cài đặt sai nào trong cấu hình Bảo mật mùa xuân của tôi không:

<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> 

Trả lời

9

Vấn đề cuối cùng cũng được giải quyết. CAS của tôi đang sử dụng HTTP và do đó cần đặt cookie an toàn thành sai.

Sửa ticketGrantingTicketCookieGenerator.xml

p:cookieSecure="false" 
+4

tốt để biết để thử nghiệm, nhưng tôi nghĩ rằng tất cả mọi người nên chạy này trên https- – chrismarx

+0

Cảm ơn bạn! Lần đầu tiên tôi tình cờ gặp câu trả lời này hơn một năm trước và chỉ bắt đầu lặn vào CAS một lần nữa. Một tham số khác có thể có vấn đề trong môi trường QA là p: cookieDomain. Nếu miền khác giữa sản xuất và QA, cài đặt này cần phải được điều chỉnh hoặc xóa hoàn toàn. Loại bỏ p: cookieDomain và thiết lập p: cookieSecure = "false" là cài đặt khoan dung nhất để nhận CAS và chạy trong QA. – AndreiM

+0

cuối cùng tôi đã nhận được +1 .. – edaklij

Các vấn đề liên quan