mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
release with automatic login and optional logout from SSO
This commit is contained in:
parent
5ef5c0ecdd
commit
1e4e38857a
3 changed files with 31 additions and 13 deletions
|
@ -8,6 +8,7 @@
|
||||||
optional_variable($config->cas_language,"");
|
optional_variable($config->cas_language,"");
|
||||||
optional_variable($config->cas_use_cas,"");
|
optional_variable($config->cas_use_cas,"");
|
||||||
optional_variable($config->cas_create_user,"0");
|
optional_variable($config->cas_create_user,"0");
|
||||||
|
optional_variable($config->cas_logout,"");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,6 +96,20 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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
|
<?php
|
||||||
include($CFG->dirroot.'/auth/ldap/config.html');
|
include($CFG->dirroot.'/auth/ldap/config.html');
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -99,12 +99,9 @@ function cas_authenticate_user_login ($username, $password) {
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
$cas_validate=true;
|
$cas_validate=true;
|
||||||
|
|
||||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||||
phpCAS::setLang($CFG->cas_language);
|
phpCAS::setLang($CFG->cas_language);
|
||||||
if (!phpCAS::isAuthenticated()){
|
phpCAS::forceAuthentication();
|
||||||
phpCAS::authenticateIfNeeded();
|
|
||||||
}
|
|
||||||
if ($CFG->cas_create_user=="0"){
|
if ($CFG->cas_create_user=="0"){
|
||||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||||
|
@ -138,10 +135,11 @@ function cas_automatic_authenticate ($user="") {
|
||||||
$cas_validate=true;
|
$cas_validate=true;
|
||||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||||
phpCAS::setLang($CFG->cas_language);
|
phpCAS::setLang($CFG->cas_language);
|
||||||
if (!phpCAS::isAuthenticated() && !$CFG->guestloginbutton){
|
$cas_user_exist=phpCAS::checkAuthentication();
|
||||||
phpCAS::authenticateIfNeeded();
|
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 ($CFG->cas_create_user=="0"){
|
||||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||||
|
@ -167,4 +165,5 @@ function cas_automatic_authenticate ($user="") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
?>
|
|
@ -1,11 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
// $Id$
|
// $Id$
|
||||||
// logout the user from CAS server (destroy the ticket)
|
// logout the user from CAS server (destroy the ticket)
|
||||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||||
|
|
||||||
include_once($CFG->dirroot.'/lib/cas/CAS.php');
|
global $CFG;
|
||||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
if ($CFG->cas_logout){
|
||||||
$backurl = $CFG->wwwroot;
|
require_once($CFG->dirroot.'/config.php');
|
||||||
phpCAS::logout($backurl);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue