Permalink
Browse files

MDL-34819: CAS authentication : Alternative logout return URL

  • Loading branch information...
gaudreaj committed Sep 19, 2012
1 parent 5d6285c commit 7d6974312f17b627f6db871a9414c3d28a5bc448
Showing with 35 additions and 0 deletions.
  1. +20 −0 auth/cas/auth.php
  2. +13 −0 auth/cas/config.html
  3. +2 −0 auth/cas/lang/en/auth_cas.php
View
@@ -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)) {
@@ -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);
@@ -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;
+ }
+ }
+ }
}
View
@@ -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)) {
@@ -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>
@@ -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)';

0 comments on commit 7d69743

Please sign in to comment.