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

Vous regardez une version antérieure (v. /wiki/spaces/CASKERB/pages/83329169/Installation+et+configuration+du+serveur+CAS+archive) de cette page.

afficher les différences afficher l'historique de la page

« Afficher la version précédente Vous regardez la version actuelle de cette page. (v. 42) afficher la version suivante »

Boot sur CD Fedora 10.

  • FQDN : cas.ifsic.univ-rennes1.fr
  • IP : 148.60.10.51

Packages supplémentaires :

  • Servers -> Web Server -> mod_auth_kerb
  • Servers -> Windows File Server (pour le test des montages SMB

Il n'est pas nécessaire de configurer l'authentification des utilisateurs sur ce serveur.

Authentification web Kerberos par Apache en utilisant mod_auth_kerb

Installation basique Apache

Installer httpd (Apache) et mod_auth_kerb et démarrer Apache :

[root@cas ~]# chkconfig httpd on
[root@cas ~]# service httpd start
Starting httpd:                          [OK]
[root@cas ~]#

Ecrire un simple script test.php dans le répertoire /var/www/html/kerb :

<?php
echo "<p>REMOTE_USER=[".$_SERVER['REMOTE_USER']."]</p>";
echo "<p>PHP_AUTH_USER=[".$_SERVER['PHP_AUTH_USER']."]</p>";
phpinfo();
?>

Tester en accédant à http://cas.ifsic.univ-rennes1.fr/kerb/test.php .

Installation mod_auth_kerb

Déclarer le client Kerberos. Sous kadmin :

[root@cas ~]# kadmin
Authenticating as principal root/admin@UNIV-RENNES1.FR with password.
Password for root/admin@UNIV-RENNES1.FR:
kadmin:  addprinc -randkey HTTP/cas.ifsic.univ-rennes1.fr
WARNING: no policy specified for HTTP/cas.ifsic.univ-rennes1.fr@UNIV-RENNES1.FR; defaulting to no policy
Principal "HTTP/cas.ifsic.univ-rennes1.fr@UNIV-RENNES1.FR" created.
kadmin:  ktadd -k /etc/httpd/conf/mod_auth_kerb.keytab HTTP/cas.ifsic.univ-rennes1.fr
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type AES-256 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type AES-128 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type Triple DES cbc mode with HMAC/sha1 added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type ArcFour with HMAC/md5 added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type DES with HMAC/sha1 added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
Entry for principal HTTP/cas.ifsic.univ-rennes1.fr with kvno 3, encryption type DES cbc mode with RSA-MD5 added to keytab WRFILE:/etc/httpd/conf/mod_auth_kerb.keytab.
kadmin:  exit
[root@cas ~]# 

Puis :

[root@cas ~]# chown apache /etc/httpd/conf/mod_auth_kerb.keytab
[root@cas ~]# chmod 640 /etc/httpd/conf/mod_auth_kerb.keytab
[root@cas ~]#

Protéger un répertoire par Kerberos en éditant /etc/httpd/conf.d/auth_kerb.conf :

<Location /kerb>
  #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>

Test

Avant de tester, ne pas oublier d'ouvrir le port 80 entrant (system-config-firewall).

Tester en accédant http://cas.ifsic.univ-rennes1.fr/kerb/test.php. Le nom de l'utilisateur doit apparaître dans les variables $_SERVER["REMOTE_USER"] et $_SERVER["PHP_AUTH_USER"] (quelque chose comme paubry@IFSIC.UNIV-RENNES1.FR).

Note : il faut configurer les navigateurs clients pour que l'authentification kerberos soit transmise au serveur web.

Il est possible de supprimer le domaine Kerberos de l'identifiant renvoyé par mod_auth_kerb en ajoutant l'option suivante à mod_auth_kerb :

KrbLocalUserMapping On

Installation Java/Maven/Tomcat

Télécharger le dernier JDK depuis http://java.sun.com/javase/downloads/index.jsp , puis exécuter :

[root@cas Download]# chmod +x jdk-6u18-linux-i586-rpm.bin
[root@cas Download]# chmod +x jdk-6u18-linux-i586-rpm.bin
[...]
Done.
[root@cas Download]# 

Ajouter le fichier /etc/profile.d/java.sh contenant les lignes suivantes :

export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH

Vérifier l'installation :

[root@cas ~]# java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
[root@cas ~]#

Installer Maven et Tomcat :

[root@cas ~]# yum install maven2 tomcat5

Version de Maven

Si jamais la version de Maven est avant 2.0.9, faire une installation manuelle depuis http://maven.apache.org/download.html :

[root@cas ~]# mvn --version
/usr/java/default
Maven version: 2.0.8
Java version: 1.6.0_18
OS name: "linux" version: "2.6.31.9-174.fc12.i686" arch: "i386" Family: "unix"
[root@cas ~]# yum remove maven2
[...]
Complete!
[root@cas ~]# cd /usr/local
[root@cas local]# wget [ftp://ftp.inria.fr/pub/Apache/maven/binaries/apache-maven-2.2.1-bin.tar.gz]
--2010-01-18 11:14:08-- [ftp://ftp.inria.fr/pub/Apache/maven/binaries/apache-maven-2.2.1-bin.tar.gz]
=> "apache-maven-2.2.1-bin.tar.gz"
Resolving ftp.inria.fr... 192.93.2.32
Connecting to ftp.inria.fr\|192.93.2.32\|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/Apache/maven/binaries ... done.
==> SIZE apache-maven-2.2.1-bin.tar.gz ... 2840961
==> PASV ... done.    ==> RETR apache-maven-2.2.1-bin.tar.gz ... done.
Length: 2840961 (2.7M) (unauthoritative)
100%[==========================================================================================================================>] 2,840,961    987K/s   in 2.8s
2010-01-18 11:14:12 (987 KB/s) - "apache-maven-2.2.1-bin.tar.gz" saved [2840961]
[root@cas local]# tar xf apache-maven-2.2.1-bin.tar.gz
[root@cas local]# ln -s apache-maven-2.2.1 maven2
[root@cas local]#

Ajouter Maven au PATH dans /etc/profile.d/java.sh :

export JAVA_HOME=/usr/java/default
export MVN_HOME=/usr/local/maven2
export PATH=$JAVA_HOME/bin:$PATH:$MVN_HOME/bin

Puis vérifier que Maven 2.2 est bien installé :

[root@cas local]# mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_18
Java home: /usr/java/jdk1.6.0_18/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.31.9-174.fc12.i686" arch: "i386" Family: "unix"
[root@cas local]#

Serveur CAS basique, en HTTP

Installation

Télécharger la dernière version de CAS depuis http://www.jasig.org/cas/download  et décompresser :

[root@cas ~]# cd /usr/local
[root@cas local]# wget http://www.ja-sig.org/downloads/cas/cas-server-3.3.5-release.tar.gz
--2010-01-18 10:47:55--  http://www.ja-sig.org/downloads/cas/cas-server-3.3.5-release.tar.gz
Resolving www.ja-sig.org... 128.112.131.108
Connecting to www.ja-sig.org|128.112.131.108|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14467126 (14M) [application/x-gzip]
Saving to: "cas-server-3.3.5-release.tar.gz"
100%[======================================================================>] 14,467,126   271K/s   in 84s
2010-01-18 10:49:19 (168 KB/s) - "cas-server-3.3.5-release.tar.gz" saved [14467126/14467126]
[root@cas local]# tar xf cas-server-3.3.5-release.tar.gz
[root@cas local]# cd cas-server-3.3.5
[root@cas cas-server-3.3.5]# cd cas-server-webapp
[root@cas cas-server-webapp]#  

Modifier le fichier src/main/webapp/WEB-INF/classes/log4j.properties en indiquant le chemin des logs :

log4j.appender.logfile.File=/var/log/tomcat5/cas.log

Générer le WAR, le copier dans Tomcat et redémarrer :

[root@cas cas-server-webapp]#  mvn package install
[root@cas cas-server-webapp]#  cp target/cas.war /var/lib/tomcat5/webapps/ROOT.war
[root@cas cas-server-webapp]#  /etc/init.d/tomcat5 restart

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

Passage de CAS en HTTPS

Génération du keystore

Rapatrier Jetty (par exemple dans /usr/local) depuis http://static.roopindersingh.com/jetty-6.1.7.jar .

Copier les clés publique (cas.ifsic.univ-rennes1.fr.pem) et privée (cas.ifsic.univ-rennes1.fr.key) dans /etc/pki/tls/private pour générer le keystore dans /etc/tomcat5 (en donnant comme mot de passe changeit) :

[root@cas private]# openssl pkcs12 -export \
>     -out cas.ifsic.univ-rennes1.fr.pkcs12 \
>     -in cas.ifsic.univ-rennes1.fr.pem \
>     -inkey cas.ifsic.univ-rennes1.fr.key
Enter Export Password:
Verifying - Enter Export Password:
[root@cas private]# java -cp /usr/local/jetty-6.1.7.jar org.mortbay.jetty.security.PKCS12Import \
>     cas.ifsic.univ-rennes1.fr.pkcs12 /etc/tomcat5/cas.ifsic.univ-rennes1.fr.keystore
Enter input keystore passphrase: changeit
Enter output keystore passphrase: changeit
Alias 0: 1
Adding key for alias 1
[root@cas private]# 

Régler les permissions du keystore :

[root@cas private]# cd /etc/tomcat5/
[root@cas tomcat5]# chgrp tomcat cas.ifsic.univ-rennes1.fr.keystore
[root@cas tomcat5]# chmod 640 cas.ifsic.univ-rennes1.fr.keystore
[root@cas tomcat5]# 

Configuration de Tomcat

Dans /etc/tomcat5/server.xml, commenter le connecteur HTTP sur le port 8080 et décommenter le connecteur HTTPS sur le port 8443 en ajoutant l'attribut :

keystoreFile="/etc/tomcat5/cas.ifsic.univ-rennes1.fr.keystore"

Test

Redémarrer Tomcat, désactiver si nécessaire le firewall pour le port 8443 et tester https://cas.ifsic.univ-rennes1.fr:8443  (user = test, password = test).

Mise en place de l'authentification LDAP

Script de déploiement de CAS

Pour faciliter le déploiement du serveur CAS, on pourra ajouter le script /usr/local/cas-server-3.3.5/deploy.sh suivant :

#!/bin/bash
/etc/init.d/tomcat5 stop
pushd /usr/local/cas-server-3.3.5/cas-server-webapp
mvn package install && rm -f /var/lib/tomcat5/webapps/ROOT.war && cp target/cas.war /var/lib/tomcat5/webapps/ROOT.war
popd
/etc/init.d/tomcat5 start

Configuration de CAS pour LDAP

Dans le fichier src/main/webapp/WEB-INF/deployerConfigContext.xml, ajouter le bean suivant pour déclarer le contexte LDAP :

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

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

Test

Redéployer le serveur CAS et tester l'authentification d'un utilisateur LDAP.

Serveur CAS avec frontal Apache

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

Mise en place d'un serveur CAS Kerberos/LDAP

Apache (avec mod_auth_kerb) va être utilisé en frontal de Tomcat.

Ajout de l'authentification Kerberos au serveur CAS

Faire exactement comme indiqué dans http://www.ja-sig.org/wiki/display/CASUM/Trusted .

Configuration de Apache en HTTPS

  • Aucune étiquette