| Balise Wiki |
|---|
{toc}
Boot sur CD Fedora 10.
* FQDN : |
| Sommaire |
|---|
Boot sur CD Fedora 10.
...
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. |
...
h2. Authentification web Kerberos par Apache en utilisant mod_auth_kerb |
...
Installation basique Apache
...
h3. Installation basique Apache Installer httpd (Apache) et mod_auth_kerb et démarrer Apache : |
...
| Bloc de code |
|---|
{code}[root@cas ~]# chkconfig httpd on
[root@cas ~]# service httpd start
Starting httpd: [OK]
[root@cas ~]# |
...
{code} Ecrire un simple script [test.php|^test.php] dans le répertoire */var/www/html/kerb* : |
...
{code |
}<?php
echo "<p>REMOTE_USER=[".$_SERVER['REMOTE_USER']."]</p>";
echo "<p>PHP_AUTH_USER=[".$_SERVER['PHP_AUTH_USER']."]</p>";
phpinfo();
?> |
...
{code} Tester en accédant à [http://cas.ifsic.univ-rennes1.fr/kerb/test.php |
...
|http://cas.ifsic.univ-rennes1.fr/kerb/test.php] . h3. Installation mod_auth_kerb |
...
Déclarer le client Kerberos. Sous kadmin : |
...
{code |
}[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 ~]# {code} Puis : |
...
{code |
}[root@cas ~]# chown apache /etc/httpd/conf/mod_auth_kerb.keytab [root@cas ~]# chmod 640 /etc/httpd/conf/mod_auth_kerb.keytab [root@cas ~]#{code}Protéger un répertoire par Kerberos en éditant */etc/httpd/conf.d/auth_kerb.conf* : |
...
{code |
}<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
...
{code} h3. 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. |
...
...
* [CASKERB:Configuration de Firefox] * [CASKERB:Configuration de Internet Explorer] Il est possible de supprimer le domaine Kerberos de l'identifiant renvoyé par mod_auth_kerb en ajoutant l'option suivante à *mod_auth_kerb* : |
...
{code |
}KrbLocalUserMapping On |
...
{code} h2. Installation Java/Maven/Tomcat |
...
Télécharger le dernier JDK depuis [http://java.sun.com/javase/downloads/index.jsp] , puis exécuter : |
...
{code |
}[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]# {code} Ajouter le fichier */etc/profile.d/java.sh* contenant les lignes suivantes : |
...
{code |
}export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH
|
...
{code} Vérifier l'installation : |
...
{code |
}[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 :
| Bloc de code | ||
|---|---|---|
{code}
Installer _Maven_ et _Tomcat_ :
{code}[root@cas ~]# yum install maven2 tomcat5 | ||
| Astuce | ||
| ||
Si jamais la version de Maven est avant {code} {tip:title=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: Bloc de code | ] : {code}[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]# {code} Ajouter Maven au PATH dans */etc/profile.d/java.sh* : {code }export JAVA_HOME=/usr/java/default export MVN_HOME=/usr/local/maven2 export PATH=$JAVA_HOME/bin:$PATH:$MVN_HOME/bin {code} Puis vérifier que Maven 2.2 est bien installé : {code }[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
...
{code} {tip} h2. Installation d'un serveur CAS basique h3. Installation Télécharger la dernière version de CAS depuis [http://www.jasig.org/cas/download |
...
] et décompresser : |
...
{code |
}[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]# {code} Modifier le fichier *src/main/webapp/WEB-INF/classes/log4j.properties* en indiquant le chemin des logs : |
...
{code |
}log4j.appender.logfile.File=/var/log/tomcat5/cas.log |
...
{code} Générer le WAR, le copier dans Tomcat et redémarrer : |
...
{code |
}[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
...
{code} h3. 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). h2. |
...
Passage |
...
en HTTPS |
...
h3. 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) : |
...
{code |
}[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]# {code} Régler les permissions du keystore : |
...
{code |
}[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
...
{code} h3. 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 : |
...
{code |
}keystoreFile="/etc/tomcat5/cas.ifsic.univ-rennes1.fr.keystore" |
Test
...
{code} h3. 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). |
...
h2. Ajout de l'authentification LDAP |
...
h3. 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 : |
...
{code |
}#!/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
...
{code} h3. 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 : |
...
{code |
}<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> {code} puis changer le handler SimpleTestUsernamePasswordAuthenticationHandler par celui-ci : |
...
{code |
}<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
...
{code} h3. 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
...
h2. Ajout d'un 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. h3. Configuration de Apache Installer le certificat du serveur en éditant */etc/httpd/conf.d/ssl.conf* et modifier les lignes suivantes dans le _virtual host_ *\_default_:443* : |
...
{code |
}#SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateFile /etc/pki/tls/private/cas.ifsic.univ-rennes1.fr.pem #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key SSLCertificateKeyFile /etc/pki/tls/private/cas.ifsic.univ-rennes1.fr.key{code} Ajouter la ligne suivante pour indiquer à Apache de passer les requêtes à Tomcat : |
...
{code |
}ProxyPass / ajp://cas.ifsic.univ-rennes1.fr:8009/ min=0 max=100 smax=50 ttl=10 route=ori-indexing |
Configuration de Tomcat
Si le connecteur AJP sur le port 8009 n'avait pas été précédemment commenté, il n'y a rien de plus à configurer au niveau de Tomcat.
Le connecteur HTTPS sur le port 8443 peut en revanche être commenté.
Test
...
{code} h3. Configuration de Tomcat Si le connecteur AJP sur le port 8009 n'avait pas été précédemment commenté, il n'y a rien de plus à configurer au niveau de Tomcat. Le connecteur HTTPS sur le port 8443 peut en revanche être commenté. h3. Test Le serveur CAS doit désormais répondre sur l'URL [https://cas.ifsic.univ-rennes1.fr |
...
] (sur le port 443 par défaut en HTTPS) |
...
Mise en place d'un serveur CAS Kerberos/LDAP
...
. h2. Ajout de l'authentification Kerberos h3. Configuration de Apache On ajoute simplement mod_auth_kerb |
...
Ajout de l'authentification Kerberos au serveur CAS
Faire exactement comme indiqué dans http://www.ja-sig.org/wiki/display/CASUM/Trusted .
...
au serveur virtuel frontal : {code}<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>{code} h3. Configuration de CAS Les instruction de configuration de CAs sont extraites de [http://www.ja-sig.org/wiki/display/CASUM/Trusted] . h4. Ajouter le support du handler trusted 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*) :<dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-trusted</artifactId> <version>${project.version}</version> </dependency> h4. 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_ :<action-state id="remoteAuthenticate"> <action bean="principalFromRemoteAction" /> <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_, _renewRequestCheck_ et _generateServiceTicket_ : {code}<decision-state id="gatewayRequestCheck"> <if test="${externalContext.requestParameterMap\['gateway'\] \!= '' && externalContext.requestParameterMap\['gateway'\] \!= null && flowScope.service \!= null}" then="redirect" else="remoteAuthenticate" /> </decision-state>{code} {code}<decision-state id="renewRequestCheck"> <if test="${externalContext.requestParameterMap\['renew'\] \!= '' && externalContext.requestParameterMap\['renew'\] \!= null}" then="remoteAuthenticate" else="generateServiceTicket" /> </decision-state>{code} {code}<action-state id="generateServiceTicket"> <action bean="generateServiceTicketAction" /> <transition on="success" to ="warn" /> <transition on="error" to="remoteAuthenticate" /> <transition on="gateway" to="redirect" /> </action-state>{code} xxx h3. Configuration de Apache en HTTPS |