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