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

...

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

...

:

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 *

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();
?>{code}


Tester en accédant à [

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 ~]# {code}

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 ~]#{code}

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>{code}

h3. Test

Avant de tester, ne pas oublier 

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

...

:

{
Bloc de code
}KrbLocalUserMapping On{code}

h2. Installation 

Installation Java/Maven/Tomcat

...

Télécharger

...

le

...

dernier

...

JDK

...

depuis

...

http://java.sun.com/javase/downloads/index.jsp

...

,

...

puis

...

exécuter

...

:

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

...

:

{
Bloc de code
}export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH
{code}


Vérifier 

Vérifier l'installation

...

:

{
Bloc de 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{code}

{tip:title=Version de Maven}Si jamais la version de Maven est avant 
Astuce
titleVersion de Maven

Si jamais la version de Maven est avant 2.0.9,

faire

une

installation

manuelle

depuis

[

http://maven.apache.org/download.html

]&nbsp;: {code}

 :

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

*

:

{

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

:

{

Bloc de 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]#
{code} {tip} h2. Installation d'un serveur CAS basique h3. Installation Télécharger la dernière version de CAS depuis [

Installation d'un serveur CAS basique

Installation

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

...

  et

...

décompresser

...

:

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

...

:

{
Bloc de code
}log4j.appender.logfile.File=/var/log/tomcat5/cas.log{code}


Générer le 

Générer le WAR,

...

le

...

copier

...

dans

...

Tomcat

...

et

...

redémarrer

...

:

{
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{code}

h3. Test


Désactiver si nécessaire le firewall pour le port 8080 (*

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

...

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)

...

:

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

...

:

{
Bloc de 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]# {code}


h3. Configuration de Tomcat


Dans *

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

...

:

{
Bloc de code
}keystoreFile="/etc/tomcat5/cas.ifsic.univ-rennes1.fr.keystore"{code}


h3. Test


Redémarrer 

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

...

Ajout

...

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

...

:

{
Bloc de 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{code}


h3. Configuration de CAS pour LDAP

Dans le fichier *

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

...

:

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

...

:

{
Bloc de 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>
{code}

h3. Test


Redéployer le serveur CAS et tester 

Test

Redéployer le serveur CAS et tester l'authentification

...

d'un

...

utilisateur

...

LDAP.

...

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.

...

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

...

:

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

...

:

{
Bloc de code
}ProxyPass / ajp://cas.ifsic.univ-rennes1.fr:8009/ min=0 max=100 smax=50 ttl=10 route=ori-indexing{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&nbsp;[

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

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

...

Ajout de l'authentification

...

Kerberos

Configuration de Apache

On ajoute simplement mod_auth_kerb

...

au

...

serveur

...

virtuel

...

frontal

...

:

{
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>{code}
h3. Configuration de CAS


Les instruction de configuration de CAs sont extraites de [

Configuration de CAS

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

...

.

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

...

)

...

:

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

...

:

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

...

:

{
Bloc de code
}<decision-state id="gatewayRequestCheck">

<if  <if
    test="${externalContext.requestParameterMap\['gateway'\] \!= '' &amp;&amp; externalContext.requestParameterMap\['gateway'\] \!= null &amp;&amp; flowScope.service \!= null}"

    then="redirect"

    else="remoteAuthenticate" />
</decision-state>
Bloc de code
{code}

{code}<decision-state id="renewRequestCheck">
  <if
    test="${externalContext.requestParameterMap\['renew'\] \!= '' &amp;&amp; externalContext.requestParameterMap\['renew'\] \!= null}"

    then="remoteAuthenticate"

    else="generateServiceTicket" />
</decision-state>
Bloc de code
{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 

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 :

Bloc de code
<bean

id="principalFromRemoteAction"

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<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.PrincipalBearingCredentialsToPrincipalResolver" />
    </list>
    </property>
    <property name="authenticationHandlers">
    <list>
    <bean class="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandler" />
    <!-- ... the others authenticationHandlers... -->
    </list>
    </property>
    </bean>

Test

ça doit marcher... ;-)

Configuration de Apache en HTTPS