Skip to content

Commit

Permalink
MDL-34819: CAS authentication : Alternative logout return URL
Browse files Browse the repository at this point in the history
  • Loading branch information
gaudreaj committed Sep 28, 2012
1 parent 5d6285c commit 7d69743
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions auth/cas/auth.php
Expand Up @@ -268,6 +268,10 @@ function process_config($config) {
if (!isset($config->certificate_path)) {
$config->certificate_path = '';
}
if (!isset($config->logout_return_url)) {
{
$config->logout_return_url = '';
}

// LDAP settings
if (!isset($config->host_url)) {
Expand Down Expand Up @@ -331,6 +335,7 @@ function process_config($config) {
set_config('multiauth', $config->multiauth, $this->pluginconfig);
set_config('certificate_check', $config->certificate_check, $this->pluginconfig);
set_config('certificate_path', $config->certificate_path, $this->pluginconfig);
set_config('logout_return_url', $config->logout_return_url, $this->pluginconfig);

// save LDAP settings
set_config('host_url', trim($config->host_url), $this->pluginconfig);
Expand Down Expand Up @@ -439,4 +444,19 @@ function sync_users($do_updates=true) {
}
parent::sync_users($do_updates);
}

/**
* Hook for logout page
*/
function logoutpage_hook() {
global $USER, $redirect;
// Only do this if the user is actually logged in via CAS
if ($USER->auth === $this->authtype) {
// Check if there is an alternative logout return url defined
if (isset($this->config->logout_return_url) && !empty($this->config->logout_return_url)) {
// Set redirect to alternative return url
$redirect = $this->config->logout_return_url;
}
}
}
}
13 changes: 13 additions & 0 deletions auth/cas/config.html
Expand Up @@ -33,6 +33,9 @@
if (!isset ($config->certificate_path)) {
$config->certificate_path = '';
}
if (!isset($config->logout_return_url)) {
$config->logout_return_url = '';
}

// set to defaults if undefined (LDAP)
if (!isset($config->host_url)) {
Expand Down Expand Up @@ -201,6 +204,16 @@ <h4><?php print_string('auth_cas_server_settings', 'auth_cas') ?></h4>
<?php print_string('auth_cas_certificate_path', 'auth_cas') ?>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string('auth_cas_logout_return_url_key', 'auth_cas') ?>:</td>
<td>
<input name="logout_return_url" type="text" size="30" value="<?php echo $config->logout_return_url ?>" />
<?php if (isset($err['logout_return_url'])) { echo $OUTPUT->error_text($err['logout_return_url']); } ?>
</td>
<td>
<?php print_string('auth_cas_logout_return_url', 'auth_cas') ?>
</td>
</tr>
<tr>
<td colspan="2">
<h4><?php print_string('auth_ldap_server_settings', 'auth_ldap') ?></h4>
Expand Down
2 changes: 2 additions & 0 deletions auth/cas/lang/en/auth_cas.php
Expand Up @@ -47,6 +47,8 @@
$string['auth_cas_language'] = 'Select language for authentication pages';
$string['auth_cas_language_key'] = 'Language';
$string['auth_cas_logincas'] = 'Secure connection access';
$string['auth_cas_logout_return_url_key'] = 'Alternative logout return URL';
$string['auth_cas_logout_return_url'] = 'Provide the URL that CAS users shall be redirected to after logging out.<br />If left empty, users will be redirected to the location that moodle will redirect users to';
$string['auth_cas_logoutcas'] = 'Select \'yes\' if you want to logout from CAS when you disconnect from Moodle';
$string['auth_cas_logoutcas_key'] = 'CAS logout option';
$string['auth_cas_multiauth'] = 'Select \'yes\' if you want to have multi-authentication (CAS + other authentication)';
Expand Down

0 comments on commit 7d69743

Please sign in to comment.