6

CAS と Spring Security を使用して、複数の Web アプリケーションに SSO を実装しようとしています。予想されるケース:
CAS - http://localhost:8080/cas/
アプリ A で保護されたコンテンツ - http: //localhost:8081/cas-client1/secure/index.html
アプリ B で保護されたコンテンツ - http: //localhost:8081/ cas-client2/secure/index.html

1) ユーザーが cas-client1 にアクセスすると、CAS ログイン フォームが表示され、認証がトリガーされます。
2) 同じユーザーが cas-client2 にアクセスすると、以前のログインが認識され、ログイン フォームは表示されません。

ただし、手順 2 を実装できませんでした。CAS ログイン フォームは引き続きユーザーに要求されるため、2 回ログインする必要があります。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>
4

1 に答える 1

9

問題は最終的に解決されます。CAS は HTTP を使用しているため、セキュア Cookie を false に設定する必要があります。

ticketGrantingTicketCookieGenerator.xml の変更

p:cookieSecure="false"
于 2010-07-21T04:28:04.590 に答える