Module SSO Central Authentication Service Central Authentication Service IUT Béziers, dépt. R&T 2017 http://www.borelly.net/ Christophe.BORELLY@iutbeziers.fr
Généralités Un même utilisateur accède en général à différents services au cours d une session (différents serveurs, différentes identités, différents mots de passe, etc...). SSO (Single Sign-On) permet à l utilisateur de ne s identifier qu une seule fois pour toute la session. 28/02/17 SSO-CAS - cb@iutbeziers.fr 2/21
Web SSO Identification associée au navigateur Web Indépendant de l identité de l utilisateur qui a ouvert la session graphique système. Utilisation de fichiers de session, de cookies HTTP,... 28/02/17 SSO-CAS - cb@iutbeziers.fr 3/21
Logiciels Web SSO CAS - Central Authentication Service (Yale) https://www.apereo.org/projects/cas https://github.com/apereo/cas/releases OpenID (2005) http://openid.net/ OAuth (2006) - RFC 6749-6750 Etc... 28/02/17 SSO-CAS - cb@iutbeziers.fr 4/21
CAS (Central Authentication Service) Version 5.0.3 du 18/02/2017 Projet Open Source (Java) Développé à l université de Yale Utilisation de tickets «opaques» ST-1-0GWvYafSqWGEUXKYCIwR-cas Possibilité de Proxy (CAS 2.0) Clients : Java, Perl, JSP, PHP, ASP, etc 28/02/17 SSO-CAS - cb@iutbeziers.fr 5/21
Serveur CAS Serveur WEB supportant : Les Servlets JAVA Les JSP (Java Server Pages). Par exemple : Apache Tomcat (http://tomcat.apache.org/) Jetty (http://www.eclipse.org/jetty/) GlassFish, JBoss,... 28/02/17 SSO-CAS - cb@iutbeziers.fr 6/21
Tickets CAS Ticket Granting Ticket (TGT) Service Ticket (ST) Proxy Granting Ticket (PGT) Proxy Ticket (PT) 28/02/17 SSO-CAS - cb@iutbeziers.fr 7/21
phpcas PHP >= 5.0 (CURL, SSL, DOM, ZLIB) https://wiki.jasig.org/display/casc/phpcas Version 1.3.4 du 16/11/2015 Le serveur CAS doit être sécurisé en HTTPS! Le serveur WEB hébergeant le client CAS n'est pas forcément sécurisé en HTTPS (mais obligatoire quand on fait du proxy CAS) 28/02/17 SSO-CAS - cb@iutbeziers.fr 8/21
Exemple phpcas client <?php require_once('cas-x.y.z/cas.php'); //phpcas::setdebug(); // Voir /tmp/phpcas.log phpcas::client(cas_version_2_0, 'pc-cas.fr',8443,'/cas'); //phpcas::setnocasservervalidation(); phpcas::setcasservercacert('/etc/httpd/ca.pem'); phpcas::forceauthentication(); printf("<p>user : [%s].</p>\n",phpcas::getuser());?> 28/02/17 SSO-CAS - cb@iutbeziers.fr 9/21
Authentification de base (1) Navigateur Client Serveur CAS Service WEB GET http://pc-client/sso/cas-client.php 302 Location: https://pc-cas.fr:8443/cas/login? service=http://pc-client/sso/cas-client.php Pas de cookie de session GET https://pc-cas.fr:8443/cas/login? service=http://pc-client/sso/cas-client.php HTML CAS login form Pas de session SSO 28/02/17 SSO-CAS - cb@iutbeziers.fr 10/21
Authentification de base (2) Navigateur Client Serveur CAS Service WEB POST https://pc-cas.fr:8443/cas/login? service=http://pc-client/sso/cas-client.php Vérification user, pass et login ticket Set-cookie: CASTGC=TGT-12345678 302 Location: http://pc-client/sso/cas-client.php? ticket=st-1-dyykuowb8dktpb926rck Création de la session SSO (TGT - Ticket Granting Ticket) et du ticket de service (ST) 28/02/17 SSO-CAS - cb@iutbeziers.fr 11/21
Authentification de base (3) Navigateur Client Serveur CAS Service WEB GET http://pc-client/sso/cas-client.php? ticket=st-1-dyykuowb8dktpb926rck Vérification du ticket GET https://pc-cas.fr:8443/cas/servicevalidate? service=http://pc-client/sso/cas-client.php& ticket=st-1-dyykuowb8dktpb926rck <cas:serviceresponse xmlns:cas='http://www.yale.edu/tp/cas'> <cas:authenticationsuccess> <cas:user>toto</cas:user> </cas:authenticationsuccess> </cas:serviceresponse> Set-cookie: JSESSION=ABCD1245 302 Location: http://pc-client/sso/cas-client.php Création du cookie de session 28/02/17 SSO-CAS - cb@iutbeziers.fr 12/21
Authentification de base (4) Navigateur Client Serveur CAS Service WEB Cookie: JSESSION=ABCD1245 GET http://pc-client/sso/cas-client.php 200 [Document HTML...] Validation du cookie de session 28/02/17 SSO-CAS - cb@iutbeziers.fr 13/21
Authentification sur un autre service «CASifié» Navigateur Client Serveur CAS Service WEB 2 GET http://pc-client2/cas/app2.php 302 Location: https://pc-cas.fr:8443/cas/login? service=http://pc-client2/cas/app2.php Cookie: CASTGC=TGT-12345678 GET https://pc-cas.fr:8443/cas/login? service=http://pc-client2/cas/app2.php Validation du TGT et création d un nouveau ticket de service 302 Location: http://pc-clien2/cas/app2.php? ticket=st-2-3tnbqefmstzvidwrlko Suite comme au 3 et 4 28/02/17 SSO-CAS - cb@iutbeziers.fr 14/21
Authentification par proxy CAS Un proxy CAS est un service CAS accessible en HTTPS et qui peut faire des requêtes vers d autres clients ou proxy CAS. Utilisé dans les portails WEB. Le serveur CAS (JAVA) doit pouvoir faire une connexion HTTPS sur le serveur WEB hébergeant le proxy CAS (il faut mettre à jour la liste des certificats de CA connus en JAVA). Il faut autoriser l'appel par proxy dans le client CAS final avec phpcas::allowproxychain(). 28/02/17 SSO-CAS - cb@iutbeziers.fr 15/21
Exemple phpcas proxy <?php require_once('cas-x.y.z/cas.php'); phpcas::proxy(cas_version_2_0,'pc-cas.fr',8443,'/cas'); //phpcas::setnocasservervalidation(); phpcas::setcasservercacert('/etc/httpd/ca.pem'); phpcas::forceauthentication(); $service='http://pc-client/sso/service.php'; if (phpcas::serviceweb($service, $err_code,$output)) { echo $output; }?> 28/02/17 SSO-CAS - cb@iutbeziers.fr 16/21
Exemple phpcas client «proxyfié» <?php require_once('cas-x.y.z/cas.php'); //phpcas::setdebug(); phpcas::client(cas_version_2_0, 'pc-cas.fr',8443,'/cas'); //phpcas::setnocasservervalidation(); phpcas::setcasservercacert('/etc/httpd/ca.pem'); phpcas::allowproxychain( new CAS_ProxyChain_Any()); phpcas::forceauthentication(); printf("<p>user : [%s].</p>\n",phpcas::getuser());?> 28/02/17 SSO-CAS - cb@iutbeziers.fr 17/21
Authentification par proxy (1) Navigateur Client Serveur CAS Proxy CAS Service WEB Vérification TLS du proxy et envoi du PGT Demande de ticket comme au 1 et 2 GET https://pc-proxy/cas-proxy.php? ticket=st-3-jdsrq24jkskjdq GET https://pc-cas.fr:8443/cas/servicevalidate? service=https://pc-proxy/cas-proxy.php& ticket=st-3-jdsrq24jkskjdq& pgturl=https://pc-proxy/cas-proxy.php GET https://pc-proxy/cas-proxy.php? pgtiou=pgtiou-1-pg3oljydblfb& pgtid=pgt-1-pkkbqnctpaij XML contenant le PGTIOU Set-cookie: JSESSION=JKLM6789 302 Location: https://pc-proxy/cas-proxy.php Validation du ticket et demande d un PGT Sauvegarde locale du PGT et PGTIOU Vérifie le PGTIOU 28/02/17 SSO-CAS - cb@iutbeziers.fr 18/21
Authentification par proxy (2) Navigateur Client Serveur CAS Proxy CAS Service WEB Cookie: JSESSION=JKLM6789 GET https://pc-proxy/cas-proxy.php GET https://pc-cas.fr:8443/cas/proxy? targetservice=http://pc-client2/cas/app2.php& pgt=pgt-1-pkkbqnctpaij Demande du ticket proxy <cas:serviceresponse xmlns:cas="http://www.yale.edu/tp/cas"> <cas:proxysuccess> <cas:proxyticket> PT-1-b98xZrQ </cas:proxyticket> </cas:proxysuccess> </cas:serviceresponse> 28/02/17 SSO-CAS - cb@iutbeziers.fr 19/21
Authentification par proxy (3) Navigateur Client Serveur CAS Proxy CAS Service WEB Validation du ticket proxy GET http://pc-client2/cas/app2.php? ticket=pt-1-b98xzrq GET https://pc-cas.fr:8443/cas/proxyvalidate? service=pc-client2/cas/app2.php& ticket=pt-1-b98xzrq <cas:serviceresponse xmlns:cas="http://www.yale.edu/tp/cas"> <cas:authenticationsuccess> <cas:user>username</cas:user> <cas:proxies> <cas:proxy>https://pc-proxy/cas-proxy.php</cas:proxy> </cas:proxies> </cas:authenticationsuccess> </cas:serviceresponse> Set-cookie + contenu 200 [Document HTML...] 28/02/17 SSO-CAS - cb@iutbeziers.fr 20/21
Références Pascal AUBRY - Julien MARCHAL - Vincent MATHIEU Single Sign-On open-source avec CAS - 12 Octobre 2003 ESUP-Portail: open source Single Sign-On with CAS EUNIS2004 https://apereo.github.io/cas/5.0.x/ 28/02/17 SSO-CAS - cb@iutbeziers.fr 21/21