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 kerb]# chkconfig httpd on [root@cas kerb]# service httpd start Starting httpd: [OK]
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 kerb]# 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 kerb]#
Puis :
[root@cas kerb]# chown apache /etc/httpd/conf/mod_auth_kerb.keytab [root@cas kerb]# chmod 640 /etc/httpd/conf/mod_auth_kerb.keytab [root@cas kerb]#
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
Mise en place d'un serveur CAS traditionnel
Installation Java/Maven/Tomcat
Télécharger le dernier JDK depuis http://java.sun.com/javase/downloads/index.jsp , puis exécuter :
# chmod \+x jdk-6u17-linux-i586-rpm.bin # ./jdk-6u17-linux-i586-rpm.bin
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 :
# java -version java version "1.6.0_0" OpenJDK Runtime Environment (IcedTea6 1.6) (fedora-23.b16.fc10-i386) OpenJDK Client VM (build 14.0-b16, mixed mode)
Installer Maven et Tomcat :
# yum install maven2 tomcat5
Si jamais la version de Maven est avant 2.0.6, faire une installation manuelle depuis http://maven.apache.org/download.html en ajoutant Maven au PATH dans /etc/profile.d/java.sh.
# mvn --version Maven version: 2.0.4 # yum remove maven2 # cd /usr/local # wget ftp://ftp.inria.fr/pub/Apache/maven/binaries/apache-maven-2.2.1-bin.tar.gz # tar xf apache-maven-2.2.1-bin.tar.gz # ln -s apache-maven-2.2.1 maven2
Installation de CAS basique en HTTP
Télécharger la dernière version de CAS depuis http://www.jasig.org/cas/download et décompresser :
# cd /usr/local # wget http://www.ja-sig.org/downloads/cas/cas-server-3.3.5-release.tar.gz # tar xf cas-server-3.3.5-release.tar.gz # cd cas-server-3.3.5 # cd 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 :
# mvn package install # cp target/cas.war /var/lib/tomcat5/webapps/ROOT.war # /etc/init.d/tomcat5 restart
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 en HTTPS
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/tomcat5 pour générer le keystore (en donnant comme mot de passe changeit) :
#openssl pkcs12 -export \ -out cas.ifsic.univ-rennes1.fr.pkcs12 \ -in cas.ifsic.univ-rennes1.fr.pem \ -inkey cas.ifsic.univ-rennes1.fr.key #java -cp /usr/local/jetty-6.1.7.jar org.mortbay.jetty.security.PKCS12Import \ cas.ifsic.univ-rennes1.fr.pkcs12 cas.ifsic.univ-rennes1.fr.keystore
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"
Désactiver si nécessaire le firewall pour le port 8443 et tester https://cas.ifsic.univ-rennes1.fr:8443 .
Mise en place de l'authentification 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>
Tester.
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 .