release with automatic login and optional logout from SSO

This commit is contained in:
phoenixfr 2005-08-26 07:48:53 +00:00
parent 5ef5c0ecdd
commit 1e4e38857a
3 changed files with 31 additions and 13 deletions

View File

@ -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 File

@ -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 File

@ -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);
}
?>