From 1e4e38857affe44c8e71a042552f4e39613d5fb0 Mon Sep 17 00:00:00 2001 From: phoenixfr Date: Fri, 26 Aug 2005 07:48:53 +0000 Subject: [PATCH] release with automatic login and optional logout from SSO --- auth/cas/config.html | 15 +++++++++++++++ auth/cas/lib.php | 15 +++++++-------- auth/cas/logout.php | 14 +++++++++----- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/auth/cas/config.html b/auth/cas/config.html index ea603acc046..964946b8ee3 100644 --- a/auth/cas/config.html +++ b/auth/cas/config.html @@ -8,6 +8,7 @@ optional_variable($config->cas_language,""); optional_variable($config->cas_use_cas,""); optional_variable($config->cas_create_user,"0"); + optional_variable($config->cas_logout,""); ?> @@ -95,6 +96,20 @@ + + cas_logout: + + cas_logout, "");?> + + + + + dirroot.'/auth/ldap/config.html'); ?> diff --git a/auth/cas/lib.php b/auth/cas/lib.php index ff348ae0b68..fa7052e421f 100644 --- a/auth/cas/lib.php +++ b/auth/cas/lib.php @@ -99,12 +99,9 @@ function cas_authenticate_user_login ($username, $password) { global $CFG; $cas_validate=true; - phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri); phpCAS::setLang($CFG->cas_language); - if (!phpCAS::isAuthenticated()){ - phpCAS::authenticateIfNeeded(); - } + phpCAS::forceAuthentication(); if ($CFG->cas_create_user=="0"){ if (record_exists('user', 'username', phpCAS::getUser())) { $user = authenticate_user_login(phpCAS::getUser(), 'cas'); @@ -138,10 +135,11 @@ function cas_automatic_authenticate ($user="") { $cas_validate=true; phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri); phpCAS::setLang($CFG->cas_language); - if (!phpCAS::isAuthenticated() && !$CFG->guestloginbutton){ - phpCAS::authenticateIfNeeded(); + $cas_user_exist=phpCAS::checkAuthentication(); + if (!$cas_user_exist && !$CFG->guestloginbutton){ + $cas_user_exist=phpCAS::forceAuthentication(); } - if (phpCAS::isAuthenticated()){ + if ($cas_user_exist){ if ($CFG->cas_create_user=="0"){ if (record_exists('user', 'username', phpCAS::getUser())) { $user = authenticate_user_login(phpCAS::getUser(), 'cas'); @@ -167,4 +165,5 @@ function cas_automatic_authenticate ($user="") { } } -?> + +?> \ No newline at end of file diff --git a/auth/cas/logout.php b/auth/cas/logout.php index 210c19a35c5..6fba17ef0a8 100644 --- a/auth/cas/logout.php +++ b/auth/cas/logout.php @@ -1,11 +1,15 @@ -dirroot.'/lib/cas/CAS.php'); - phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri); - $backurl = $CFG->wwwroot; - phpCAS::logout($backurl); + global $CFG; + if ($CFG->cas_logout){ + require_once($CFG->dirroot.'/config.php'); + include_once($CFG->dirroot.'/lib/cas/CAS.php'); + phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri); + $backurl = $CFG->wwwroot; + phpCAS::logout($backurl); + } ?> \ No newline at end of file