From c07fcc13839ff928b9df0dd48b8e710f1945e0b8 Mon Sep 17 00:00:00 2001 From: Inaki Date: Thu, 18 Nov 2010 00:09:02 +0000 Subject: [PATCH] auth/cas: MDL-25062 CAS authentication plugin does not validate the CAS server certificate The CAS protocol security model requires that you verify the cas server certificate before you trust the answer (valid authentication and username etc.). Credit goes to Joachim Fritschi for reporting it and providing a patch. --- auth/cas/auth.php | 10 ++++++++++ auth/cas/config.html | 46 +++++++++++++++++++++++++++++++++++++++++++ lang/en_utf8/auth.php | 10 +++++++--- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/auth/cas/auth.php b/auth/cas/auth.php index f551c769c25..758f85054d8 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -114,8 +114,12 @@ class auth_plugin_cas extends auth_plugin_base { // Connection to CAS server $this->connectCAS(); + if($this->config->certificate_check && $this->config->certificate_path){ + phpCAS::setCasServerCACert($this->config->certificate_path); + }else{ // Don't try to validate the server SSL credentials phpCAS::setNoCasServerValidation(); + } // Gestion de la connection CAS si acc�s direct d'un ent ou autre if (phpCAS::checkAuthentication()) { @@ -248,6 +252,10 @@ if ( !is_object($PHPCAS_CLIENT) ) { $config->logoutcas = ''; if (!isset ($config->multiauth)) $config->multiauth = ''; + if (!isset ($config->certificate_check)) + $config->certificate_check = ''; + if (!isset ($config->certificate_path)) + $config->certificate_path = ''; // LDAP settings if (!isset($config->host_url)) { $config->host_url = ''; } @@ -290,6 +298,8 @@ if ( !is_object($PHPCAS_CLIENT) ) { set_config('proxycas', $config->proxycas, 'auth/cas'); set_config('logoutcas', $config->logoutcas, 'auth/cas'); set_config('multiauth', $config->multiauth, 'auth/cas'); + set_config('certificate_check', $config->certificate_check, 'auth/cas'); + set_config('certificate_path', $config->certificate_path, 'auth/cas'); // save LDAP settings set_config('host_url', $config->host_url, 'auth/cas'); set_config('ldapencoding', $config->ldapencoding, 'auth/cas'); diff --git a/auth/cas/config.html b/auth/cas/config.html index e1539692ff1..ab287f3ff20 100644 --- a/auth/cas/config.html +++ b/auth/cas/config.html @@ -48,6 +48,14 @@ $config->multiauth = ''; + if (!isset ($config->certificate_check)) + + $config->certificate_check = ''; + + if (!isset ($config->certificate_path)) + + $config->certificate_path = ''; + // set to defaults if undefined (LDAP) if (!isset($config->host_url)) @@ -364,6 +372,44 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there? + + + : + + + + certificate_check, ''); ?> + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + diff --git a/lang/en_utf8/auth.php b/lang/en_utf8/auth.php index 5c6184e2692..1e3ce8c9f91 100644 --- a/lang/en_utf8/auth.php +++ b/lang/en_utf8/auth.php @@ -36,9 +36,13 @@ $string['auth_nologintitle'] = 'No login'; $string['auth_cas_proxycas_key'] = "Proxy mode"; $string['auth_cas_logoutcas_key'] = "Logout CAS"; $string['auth_cas_multiauth_key'] = "Multi-authentication"; -$string['auth_cas_proxycas'] = "Turn this to 'yes'' if you use CASin proxy-mode"; -$string['auth_cas_logoutcas'] = "Turn this to 'yes'' if tou want to logout from CAS when you deconnect from Moodle"; -$string['auth_cas_multiauth'] = "Turn this to 'yes'' if you want to have multi-authentication (CAS + other authentication)"; +$string['auth_cas_certificate_check_key'] = "Server validation"; +$string['auth_cas_certificate_path_key'] = "Certificate path"; +$string['auth_cas_proxycas'] = "Turn this to ''yes'' if you use CASin proxy-mode"; +$string['auth_cas_logoutcas'] = "Turn this to ''yes'' if tou want to logout from CAS when you deconnect from Moodle"; +$string['auth_cas_multiauth'] = "Turn this to ''yes'' if you want to have multi-authentication (CAS + other authentication)"; +$string['auth_cas_certificate_check'] = "Turn this to ''yes'' if you want to validate the server certificate"; +$string['auth_cas_certificate_path'] = "Path of the CA chain file (PEM Format) to validate the server certificate"; $string['accesCAS'] = "CAS users"; $string['accesNOCAS'] = "other users"; $string['CASform'] = "Authentication choice";