Diferencia entre revisiones de «HOW TO: Integración CAS»

De Thubanpedia
Saltar a: navegación, buscar
(Página creada con «{{Languages}} = '''HOW TO: Configurar la integración con CAS (JASIG Central Authentication Service)''' = La plataforma permite integrarse con CAS de manera transparent...»)
 
(HOW TO: Configurar la integración con CAS (JASIG Central Authentication Service))
 
Línea 38: Línea 38:
  
 
El contenido del archivo CAS es el siguiente:
 
El contenido del archivo CAS es el siguiente:
 
  
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?xml version="1.0" encoding="UTF-8"?>
Línea 49: Línea 48:
 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
 
     <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
 
     <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
  <property name="filterInvocationDefinitionSource">
+
          <property name="filterInvocationDefinitionSource">
  <value>
+
              <value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
+
                  CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT     /**=httpSessionContextIntegrationFilter,casSingleSignOutFilter,casProcessingFilter,securityContextHolderAwareRequestFilter,exceptionTranslationFilter,zkEventExceptionFilter,filterInvocationInterceptor
+
                  PATTERN_TYPE_APACHE_ANT
</value>
+
/**=httpSessionContextIntegrationFilter,casSingleSignOutFilter,casProcessingFilter,securityContextHolderAwareRequestFilter,exceptionTranslationFilter,zkEventExceptionFilter,filterInvocationInterceptor
</property>
+
                    </value>
</bean>
+
                </property>
+
        </bean>
  <bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
+
        <bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint">
+
                <property name="authenticationEntryPoint">
<bean id="casProcessingFilterEntryPoint" class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
+
                        <bean id="casProcessingFilterEntryPoint" class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
<property name="loginUrl" value="${cas.server.login}"/>
+
                                        <property name="loginUrl" value="${cas.server.login}"/>
<property name="serviceProperties" ref="serviceProperties"/>
+
                                        <property name="serviceProperties" ref="serviceProperties"/>
</bean>
+
                        </bean>
</property>
+
                </property>
</bean>
+
        </bean>
 
+
    <!-- Does the CAS ticket validation and user details loading -->
  <!-- Does the CAS ticket validation and user details loading -->
+
  <bean id="casAuthenticationProvider" class="org.springframework.security.providers.cas.CasAuthenticationProvider">
    <bean id="casAuthenticationProvider" class="org.springframework.security.providers.cas.CasAuthenticationProvider">
+
 
         <property name="userDetailsService" ref="userDetailsService"/>
 
         <property name="userDetailsService" ref="userDetailsService"/>
 
         <property name="serviceProperties" ref="serviceProperties"/>
 
         <property name="serviceProperties" ref="serviceProperties"/>
 
         <property name="ticketValidator">
 
         <property name="ticketValidator">
            <bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
+
              <bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
                <constructor-arg index="0" value="${cas.server}"/>
+
                    <constructor-arg index="0" value="${cas.server}"/>
            </bean>
+
            </bean>
 
         </property>
 
         </property>
 
         <property name="key" value="my_password_for_this_auth_provider_only"/>
 
         <property name="key" value="my_password_for_this_auth_provider_only"/>
 
     </bean>
 
     </bean>
 
+
        <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
<bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
+
              <property name="providers">
<property name="providers">
+
                  <list>
<list>
+
                        <ref local="casAuthenticationProvider"/>
<ref local="casAuthenticationProvider"/>
+
                  </list>
</list>
+
              </property>
</property>
+
    </bean>
</bean>
+
    <!-- handles a logout request from the CAS server -->
    <!-- handles a logout request from the CAS server -->
+
        <bean id="casSingleSignOutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/>
    <bean id="casSingleSignOutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/>
+
    <!-- performs CAS authentication -->
+
        <bean id="casProcessingFilter" class="org.springframework.security.ui.cas.CasProcessingFilter">
    <!-- performs CAS authentication -->
+
            <property name="authenticationManager" ref="authenticationManager"/>
    <bean id="casProcessingFilter" class="org.springframework.security.ui.cas.CasProcessingFilter">
+
            <property name="authenticationFailureUrl" value="/403.jsp"/>
        <property name="authenticationManager" ref="authenticationManager"/>
+
            <property name="alwaysUseDefaultTargetUrl" value="false"/>
        <property name="authenticationFailureUrl" value="/403.jsp"/>
+
            <property name="defaultTargetUrl" value="/"/>
        <property name="alwaysUseDefaultTargetUrl" value="false"/>
+
        </bean>
        <property name="defaultTargetUrl" value="/"/>
+
          <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
    </bean>
+
              <property name="authenticationManager" ref="authenticationManager"/>
+
              <property name="accessDecisionManager">
  <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
+
                        <bean class="org.springframework.security.vote.AffirmativeBased">
<property name="authenticationManager" ref="authenticationManager"/>
+
                                <property name="allowIfAllAbstainDecisions" value="false"/>
<property name="accessDecisionManager">
+
                                <property name="decisionVoters">
<bean class="org.springframework.security.vote.AffirmativeBased">
+
                                        <list>
<property name="allowIfAllAbstainDecisions" value="false"/>
+
                                            <bean class="org.springframework.security.vote.AuthenticatedVoter"/>
<property name="decisionVoters">
+
                                        </list>
<list>
+
                                </property>
<bean class="org.springframework.security.vote.AuthenticatedVoter"/>
+
                          </bean>
</list>
+
              </property>
</property>
+
              <property name="objectDefinitionSource">
</bean>
+
                          <value>
</property>
+
                              CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
<property name="objectDefinitionSource">
+
                              PATTERN_TYPE_APACHE_ANT
<value>
+
                                  /**=IS_AUTHENTICATED_REMEMBERED
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
+
                          </value>
PATTERN_TYPE_APACHE_ANT
+
                </property>
/**=IS_AUTHENTICATED_REMEMBERED
+
            </bean>
</value>
+
</property>
+
</bean>
+
 
  </beans>
 
  </beans>

Última revisión de 10:50 16 oct 2014


HOW TO: Configurar la integración con CAS (JASIG Central Authentication Service)

La plataforma permite integrarse con CAS de manera transparente para autenticación de usuarios. Se deben llevar a cabo los siguientes pasos:

1. Configurar en context.properties las URLs de los servicios y las URLs del servidor CAS.

2. Agregar la configuración de CAS al archivo user-application-context.xml.


1. Configuracion de context.properties

Para habilitar el login integrado con CAS es necesario configurar los siguientes parámetros del archivo "context.properties":

  • cas.thubanweb.service: la URL del servicio de Thuban® PowerDesk. Por lo general: http(s)://<server>:<port>/<Contexto>/j_spring_cas_security_check

Ejemplo: https://server:8443/PowerDesk/j_spring_cas_security_check

  • cas.thubanserver.service: la URL del servicio de Thuban® Server. Por lo general: http(s)://<server>:<port>/<Contexto>/j_spring_cas_security_check

Ejemplo: https://server:8443/Server/j_spring_cas_security_check

  • cas.server: la URL del servidor CAS.

Ejemplo: https://localhost:8443/cas-server-webapp-3.3.1/

  • cas.server.login: la URL de login del servidor CAS.

Ejemplo: https://localhost:8443/cas-server-webapp-3.3.1/login


2. Agregar la configuración de CAS al archivo user-application-context.xml

Para agregar la configuración de CAS solo es necesario utilizar el siguiente import y ubicar el archivo cas-integration.xml en la carpeta de contexto:

<source lang="xml"><import resource="file:${thuban.context}cas-integration.xml"/></source>


El contenido del archivo CAS es el siguiente:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
         <property name="filterInvocationDefinitionSource">
             <value>
                 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                 PATTERN_TYPE_APACHE_ANT
/**=httpSessionContextIntegrationFilter,casSingleSignOutFilter,casProcessingFilter,securityContextHolderAwareRequestFilter,exceptionTranslationFilter,zkEventExceptionFilter,filterInvocationInterceptor
                   </value>
                </property>
       </bean>
       <bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
                <property name="authenticationEntryPoint">
                       <bean id="casProcessingFilterEntryPoint" class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
                                       <property name="loginUrl" value="${cas.server.login}"/>
                                       <property name="serviceProperties" ref="serviceProperties"/>
                       </bean>
                </property>
       </bean>
 <bean id="casAuthenticationProvider" class="org.springframework.security.providers.cas.CasAuthenticationProvider">
       <property name="userDetailsService" ref="userDetailsService"/>
       <property name="serviceProperties" ref="serviceProperties"/>
       <property name="ticketValidator">
             <bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
                   <constructor-arg index="0" value="${cas.server}"/>
            </bean>
       </property>
       <property name="key" value="my_password_for_this_auth_provider_only"/>
   </bean>
        <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
             <property name="providers">
                  <list>
                       <ref local="casAuthenticationProvider"/>
                  </list>
             </property>
    </bean>
        <bean id="casSingleSignOutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/>
        <bean id="casProcessingFilter" class="org.springframework.security.ui.cas.CasProcessingFilter">
            <property name="authenticationManager" ref="authenticationManager"/>
            <property name="authenticationFailureUrl" value="/403.jsp"/>
            <property name="alwaysUseDefaultTargetUrl" value="false"/>
            <property name="defaultTargetUrl" value="/"/>
       </bean>
          <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
              <property name="authenticationManager" ref="authenticationManager"/>
              <property name="accessDecisionManager">
                        <bean class="org.springframework.security.vote.AffirmativeBased">
                               <property name="allowIfAllAbstainDecisions" value="false"/>
                               <property name="decisionVoters">
                                       <list>
                                            <bean class="org.springframework.security.vote.AuthenticatedVoter"/>
                                       </list>
                               </property>
                         </bean>
              </property>
              <property name="objectDefinitionSource">
                         <value>
                              CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                              PATTERN_TYPE_APACHE_ANT
                                 /**=IS_AUTHENTICATED_REMEMBERED
                         </value>
               </property>
            </bean>
</beans>