function samlauth_sls in SAML Authentication 7
Menu callback for /saml/sls.
1 string reference to 'samlauth_sls'
- samlauth_menu in ./
samlauth.module - Implements hook_menu().
File
- ./
samlauth.module, line 272 - Provides SAML authentication capabilities.
Code
function samlauth_sls() {
$url = '';
try {
// There are two valid cases here:
// - We're processing a LogoutRequest, which will return a URL to redirect
// to (which is the IdP); the RelayState is not for us.
// - We're processing a LogoutResponse, which will return NULL; the
// RelayState is meant for us to process.
$auth = samlauth_get_saml2_auth();
$url = $auth
->processSLO(FALSE, NULL, (bool) variable_get('samlauth_logout_reuse_sigs'), NULL, TRUE);
$errors = $auth
->getErrors();
if (empty($errors)) {
if (!$url) {
// We should be able to trust the RelayState parameter at this point
// because the response from the IDP was verified.
if (isset($_REQUEST['RelayState'])) {
$url = $_REQUEST['RelayState'];
}
}
// Log out the user, since the logout already happened on the server.
if (user_is_logged_in()) {
module_load_include('pages.inc', 'user');
user_logout_current_user();
}
}
else {
drupal_set_message('SLS error: ' . implode(', ', $errors), 'error');
}
} catch (Exception $e) {
drupal_set_message('SLS error: ' . $e
->getMessage(), 'error');
}
drupal_goto($url ?: '<front>');
}