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

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 avec system-config-authentication sur ce serveur (les utilisateurs n'ont pas à se connecter sur le serveur CAS). Il faut néanmoins installer le fichier /etc/krb5.conf :

Bloc de code
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = UNIV-RENNES1.FR
 default_etypes = des3-hmac-sha1 des-cbc-crc
 default_tkt_enctypes = des3-hmac-sha1 des-cbc-crc
 default_tgs_enctypes = des3-hmac-sha1 des-cbc-crc
 permitted_enctypes = des3-hmac-sha1 des-cbc-crc rc4-hmac
 ticket_lifetime = 24h
 forwardable = yes

[realms]
 UNIV-RENNES1.FR = {
  kdc = kerb.ifsic.univ-rennes1.fr:88
  admin_server = kerb.ifsic.univ-rennes1.fr:749
  default_domain = univ-rennes1.fr
 }

[domain_realm]
 .univ-rennes1.fr = UNIV-RENNES1.FR
 univ-rennes1.fr = UNIV-RENNES1.FR

[appdefaults]
 pam = {
   debug = false
   ticket_lifetime = 36000
   renew_lifetime = 36000
   forwardable = true
   krb4_convert = false
 }

Debuggage

Apache

Modifier la directive LogLevel du fichier /etc/httpd/conf/httpd.conf :

Bloc de code
LogLevel debug

Les logs sont dans le répertoire /var/log/httpd.

CAS

Ajouter dans le fichier src/main/webapp/WEB-INF/classes/log4j.properties la ligne suivante :

Bloc de code
log4j.logger.org.jasig.cas=DEBUG

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

Authentification web Kerberos par Apache en utilisant mod_auth_kerb

Installation basique Apache

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

Bloc de code
[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 :

Bloc de code
<?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 :

Bloc de 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 ~]# 

Puis :

Bloc de 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 ~]#

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

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

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

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

...

Debuggage

Apache

Modifier la directive LogLevel du fichier /etc/httpd/conf/httpd.conf :

Bloc de code
LogLevel debug

Les logs sont dans le répertoire /var/log/httpd.

CAS

Ajouter dans le fichier src/main/webapp/WEB-INF/classes/log4j.properties la ligne suivante :

Bloc de code
log4j.logger.org.jasig.cas=DEBUG

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

Installation Java/Maven/Tomcat

...

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

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

...

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>

Test

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

...

Le connecteur HTTPS sur le port 8443 peut en revanche être commenté.

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

...

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.adaptors.trusted.authentication.principal.PrincipalBearingCredentialsToPrincipalResolver" />
      </list>
    </property>
    <property name="authenticationHandlers">
      <list>
        <bean class="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

ça doit marcher...