CAS et Kerberos
Pages enfant
  • Installation et configuration du serveur CAS (archive)

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Les logs se trouvent dans le répertoire /var/log/tomcat5.

La mise au point la plus difficile est celle de Kerberos. Les logs en debug de Krb5LoginModule se trouvent dans catalina.out.

Test

Désactiver si nécessaire le firewall pour le port 8080 (system-config-firewall) et tester http://cas.ifsic.univ-rennes1.fr:8080 (user = test, password = test).

...

Bloc de code
xml
xml
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
  <property name="pooled" value="true"/>
  <property name="urls">
    <list>
      <value>ldap://ldapglobal.univ-rennes1.fr/</value>
    </list>
  </property>
  <property name="userDn" value=""/>
  <property name="password" value=""/>
  <property name="baseEnvironmentProperties">
    <map>
      <entry>
       <key>
         <value>java.naming.security.authentication</value>
       </key>
       <value>simple</value>
      </entry>
     </map>
  </property>
</bean>

puis changer le handler SimpleTestUsernamePasswordAuthenticationHandler par celui-ci :

Bloc de code
xml
xml
<bean
   class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler" >
     <property name="filter" value="uid=%u,ou=people,dc=univ-rennes1,dc=fr" />
     <property name="contextSource" ref="contextSource" />
</bean>

...

On va dans cette partie configurer un frontal Apache sur le port 443, qui va accéder au Tomcat du serveur CAS en AJP sur le port 8009.

Configuration de Apache

Remarque

Il n'est pas obligatoire de mettre un frontal Apache devant Tomcat, mais cela délègue le chiffrement à Apache au lieu de Tomcat et simplifie l'admisnitration système (cette architecture est employée de manière générale sur les plateformes d'exploitation).

Configuration de Apache

Installer le certificat du serveur en éditant /etc/Installer le certificat du serveur en éditant /etc/httpd/conf.d/ssl.conf et modifier les lignes suivantes dans le virtual host _default_:443 :

...

Ajout de l'authentification Kerberos

Configuration de Apache

On ajoute simplement mod_auth_kerb au serveur virtuel frontal :

Bloc de code
<Location />
  #SSLRequireSSL
  AuthType KerberosV5
  AuthName "Kerberos Login"
  KrbMethodNegotiate On
  KrbMethodK5Passwd Off
  KrbAuthRealms UNIV-RENNES1.FR
  Krb5KeyTab /etc/httpd/conf/mod_auth_kerb.keytab
  #require valid-user
</Location>

Bien noter que l'on ne force pas l'authentification Kerberos (la directive require valid-user est commentée) pour que le serveur CAS bascule sur une authentification LDAP si l'authentification Kerberos n'est pas vérifiée.

Configuration de CAS

Les instruction de configuration de CAS sont extraites de http://www.ja-sig.org/wiki/display/CASUM/Trusted .

...

La documentation de référence est http://www.ja-sig.org/wiki/display/CASUM/SPNEGO .

Configuration de CAS

Ajouter le support du handler spnego

Editer le fichier <cas-home>/cas-server-webapp/pom.xml et ajouter la dépendance suivante (par exemple juste après la dépendance vers le module cas-server-support-ldap) :

Bloc de code
xml
xml
<dependency>
     <groupId>${project.groupId}</groupId>
     <artifactId>cas-server-support-spnego</artifactId>
     <version>${project.version}</version>
</dependency>

Modifier le login webflow

Editer le fichier <cas-home>/cas-server-webapp/pom.xml et ajouter la dépendance suivante (par exemple juste après la dépendance vers le module cas-server-support-ldap) src/main/webapp/WEB-INF/login-webflow.xml et ajouter l'état suivant juste avant l'état viewLoginForm :

Bloc de code
xml
xml
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-trusted</artifactId>

<version>${project.version}</version>
</dependency>

Modifier le login webflow

Editer le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/login-webflow.xml et ajouter l'état suivant juste avant l'état viewLoginForm :

Bloc de code
xmlxml
<action-state id="remoteAuthenticate">
<action bean="principalFromRemoteAction" />
<action-state id="startAuthenticate">
  <action bean="negociateSpnego" />
  <transition on="success" to="spnego" />
</action-state>

<action-state id="spnego">
  <action bean="spnego" />
  <transition on="success" to="sendTicketGrantingTicket" />
  <transition on="error" to="viewLoginForm" />
</action-state>

Dans ce même fichier, remplacer les références à viewLoginForm par remoteAuthenticate pour les trois decision-state gatewayRequestCheck, et renewRequestCheck et generateServiceTicket :

Bloc de code
xml
xml
<decision-state id="gatewayRequestCheck">
  <if
    test="${externalContext.requestParameterMap['gateway'] != '' &amp;&amp; externalContext.requestParameterMap['gateway'] != null &amp;&amp; flowScope.service != null}"
    then="redirect"
    else="remoteAuthenticatestartAuthenticate" />
</decision-state>
Bloc de code
xml
xml
<decision-state id="renewRequestCheck">
  <if
    test="${externalContext.requestParameterMap['renew'] != '' &amp;&amp; externalContext.requestParameterMap['renew'] != null}"
    then="remoteAuthenticatestartAuthenticate"
    else="generateServiceTicket" />
</decision-state>
Bloc de code

Déclarer le bean implémentant le nouvel état du webflow en ajoutant les lignes suivantes dans le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/cas-servlet.xml (par exemple juste avant le bean authenticationViaFormAction) :

Bloc de code
xml
xml
<bean
   
xmlxml
<action-state id="generateServiceTicketnegociateSpnego">
   <action beanclass="generateServiceTicketActionorg.jasig.cas.support.spnego.web.flow.SpnegoNegociateCredentialsAction" />

<bean
   <transition onid="successspnego"
 to   class="warn" />
  <transition on="error" to="remoteAuthenticate" />
  <transition on="gateway" to="redirect" org.jasig.cas.support.spnego.web.flow.SpnegoCredentialsAction">
	<property name="centralAuthenticationService" ref="centralAuthenticationService"/>
</action-state>bean>

Modifier le schéma d'authentification

Pour modifier le schéma d'authentification, éditer Déclarer le bean implémentant le nouvel état du webflow en ajoutant les lignes suivantes dans le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/cas-servletdeployerConfigContext.xml (par exemple juste avant le bean authenticationViaFormAction) : et modifier le bean authenticationManager en ajoutant :

  • PrincipalBearingCredentialsToPrincipalResolver après les resolvers existants de credentialsToPrincipalResolvers
  • PrincipalBearingCredentialsAuthenticationHandler avant les handlers existants de authenticationHandlers
Bloc de code
xml
xml
<bean
  id="principalFromRemoteActionauthenticationManager"
  class="org.jasig.cas.adaptors.trusted.web.flow.PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction"
  p:centralAuthenticationService-ref="centralAuthenticationService" />

Modifier le schéma d'authentification

Pour modifier le schéma d'authentification, éditer le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/deployerConfigContext.xml et modifier le bean authenticationManager en ajoutant :

  • PrincipalBearingCredentialsToPrincipalResolver après les resolvers existants de credentialsToPrincipalResolvers
  • PrincipalBearingCredentialsAuthenticationHandler avant les handlers existants de authenticationHandlers
authentication.AuthenticationManagerImpl">
  <property name="credentialsToPrincipalResolvers">
    <list>
      <!--  ... the others credentialsToPrincipalResolvers ... -->
      <bean class="org.jasig.cas.support.spnego.authentication.principal.SpnegoCredentialsToPrincipalResolver" />
    </list>
  </property>
  <property name="authenticationHandlers">
    <list>
      <bean class="org.jasig.cas.support.spnego.authentication.handler.support.JCIFSSpnegoAuthenticationHandler">
	<property name="authentication">
	  <bean class="jcifs.spnego.Authentication" />
	</property>
	<property name="principalWithDomainName" value="true" />
	<property name="NTLMallowed" value="false"/>
      </bean>
      <!--  ... the others authenticationHandlers... -->
    </list>
  </property>
</bean>

Le bean authenticationManager doit ainsi ressembler à :

Bloc de code
xml
xml
<bean   id="authenticationManager"
        class="org.jasig.cas.authentication.AuthenticationManagerImpl">
    <property name="credentialsToPrincipalResolvers">
      <list>
        <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" />
        <bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
        <bean class="org.jasig.cas.support.spnego.authentication.principal.SpnegoCredentialsToPrincipalResolver" />
      </list>
    </property>
    <property name="authenticationHandlers">
      <list>
        <bean class="org.jasig.cas.support.spnego.authentication.handler.support.JCIFSSpnegoAuthenticationHandler">
	  <property name="authentication">
	    <bean class="jcifs.spnego.Authentication" />
	  </property>
	  <property name="principalWithDomainName" value="true" />
	  <property name="NTLMallowed" value="false"/>
      </bean>
      <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
              p:httpClient-ref="httpClient" />
	
Bloc de code
xmlxml
<bean id="authenticationManager" class="org.jasig.cas.authentication.AuthenticationManagerImpl">
  <property name="credentialsToPrincipalResolvers">
    <list>
      <!--  ... the others credentialsToPrincipalResolvers ... -->
      <bean class="org.jasig.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredentialsToPrincipalResolverldap.FastBindLdapAuthenticationHandler" />
      </list>
  </property>
  <property name="authenticationHandlers">
    <property name="filter" value="uid=%u,ou=people,dc=univ-rennes1,dc=fr" />
     <list>
     <property <bean class="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandlername="contextSource" ref="contextSource" />
      <!--  ... the others authenticationHandlers... -->
  </bean>
      </list>
    </property>
</bean>

Le bean authenticationManager doit ainsi ressembler à Ajouter enfin le bean jcifsConfig, qui done les options de configuration de JCIFS :

xml
Bloc de code
xml
<bean   idname="authenticationManager"
       jcifsConfig" class="org.jasig.cas.support.spnego.authentication.AuthenticationManagerImplhandler.support.JCIFSConfig">
    <property name="credentialsToPrincipalResolvers">
      <list>name="jcifsServicePrincipal"
        <bean classvalue="org.jasig.HTTP/cas.authenticationifsic.principaluniv-rennes1.UsernamePasswordCredentialsToPrincipalResolverfr" />
  <property
      <bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
   name="kerberosDebug"
      value="true" />
  <property
      name="kerberosRealm"
     <bean classvalue="org.jasig.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredentialsToPrincipalResolverUNIV-RENNES1.FR" />
  <property
    </list>
  name="kerberosKdc"
  </property>
    <property namevalue="authenticationHandlers"kerb.ifsic.univ-rennes1.fr" />
  <property
    <list>
  name="loginConf"
      <bean classvalue="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandler" />
        <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
              p:httpClient-ref="httpClient" />
	<bean class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler" >
          <property name="filter" value="uid=%u,ou=people,dc=univ-rennes1,dc=fr" />
          <property name="contextSource" ref="contextSource" />
        </bean>
      </list>
    </property>
</bean>

Test

/usr/local/cas-server-3.3.5/cas-server-webapp/src/main/webapp/WEB-INF/login.conf" />

Configuration de JCIFS

La configuration de JCIFS se fait également dans le fichier login.conf pointé par le bean jcifsConfig. Créer ce fichier avec le contenu suivant :

Bloc de code
jcifs.spnego.initiate {
  com.sun.security.auth.module.Krb5LoginModule
  required
  storeKey=true
  doNotPrompt=true
  useKeyTab=true
  keyTab="/etc/http.keytab"
  principal="HTTP/cas.ifsic.univ-rennes1.fr@UNIV-RENNES1.FR"
  realm="UNIV-RENNES1.FR"
  debug=true;
};
jcifs.spnego.accept {
  com.sun.security.auth.module.Krb5LoginModule
  required
  storeKey=true
  doNotPrompt=true
  useKeyTab=true
  keyTab="/etc/http.keytab"
  principal="HTTP/cas.ifsic.univ-rennes1.fr@UNIV-RENNES1.FR"
  realm="UNIV-RENNES1.FR"
  debug=true;
};

Configuration de Tomcat

Il faut passer à la JVM qui exécute Tomcat l'option -Djavax.security.auth.useSubjectCredsOnly=false, par exemple en éditant le fichier /etc/tomcat5/tomcat5.conf et en ajoutant la ligne suivante :

Bloc de code
JAVA_OPTS="$JAVA_OPTS \-Djavax.security.auth.useSubjectCredsOnly=false"

Test

Un navigateur bien configuré et possédant des credentials Kerberos valides doit maintenant se connecter au serveur CAS sans aucune interaction.ça doit marcher...