Permalink
Browse files

release with automatic login and optional logout from SSO

  • Loading branch information...
1 parent 5ef5c0e commit 1e4e38857affe44c8e71a042552f4e39613d5fb0 phoenixfr committed Aug 26, 2005
Showing with 31 additions and 13 deletions.
  1. +15 −0 auth/cas/config.html
  2. +7 −8 auth/cas/lib.php
  3. +9 −5 auth/cas/logout.php
View
@@ -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 @@
</td>
</tr>
+<tr valign="top" class="required">
+ <td align="right">cas_logout:</td>
+ <td>
+ <?php
+ unset($options);
+ $options[0] = get_string("no");
+ $options[1] = get_string("yes");
+
+ choose_from_menu ($options, "cas_logout", $config->cas_logout, "");?>
+ </td><td>
+ <?php print_string("auth_cas_logout","auth") ?>
+ </td>
+</tr>
+
<?php
include($CFG->dirroot.'/auth/ldap/config.html');
?>
View
@@ -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="") {
}
}
-?>
+
+?>
View
@@ -1,11 +1,15 @@
-<?php
+<?php
// $Id$
// logout the user from CAS server (destroy the ticket)
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
- 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);
+ 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);
+ }
?>

0 comments on commit 1e4e388

Please sign in to comment.