another try

This commit is contained in:
fbsanchez 2020-10-19 17:42:50 +02:00
parent f6020e8791
commit 987e77271e
1 changed files with 18 additions and 40 deletions

View File

@ -404,17 +404,21 @@ if (! isset($config['id_user'])) {
$nick_in_db = $saml_user_id;
if (!$nick_in_db) {
$samlid = $_SESSION['samlid'];
if ($config['auth'] !== 'saml' || (bool) get_parameter('LogoutState')) {
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
if ($config['auth'] == 'saml' && empty($samlid) === false) {
if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
enterprise_include_once('include/auth/saml.php');
enterprise_hook('saml_logout', [$samlid]);
}
// Process logout.
include 'general/logoff.php';
}
} else {
// process_user_login is a virtual function which should be defined in each auth file.
@ -965,48 +969,22 @@ if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) {
if (isset($_GET['bye'])) {
$iduser = $_SESSION['id_usuario'];
if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
enterprise_include_once('include/auth/saml.php');
$samlid = $_SESSION['samlid'];
$saml_logout_state = (string) get_parameter('LogoutState', '');
if (empty($saml_logout_state) === false) {
try {
$state = \SimpleSAML\Auth\State::loadState(
$saml_logout_state,
'MyLogoutState'
);
$ls = $state['saml:sp:LogoutStatus'];
// Only works for SAML SP.
if ($ls['Code'] === 'urn:oasis:names:tc:SAML:2.0:status:Success'
&& isset($ls['SubCode']) === false
) {
// Successful logout.
$config['logout_msg'] = 'You have been logged out.';
} else {
// Logout failed. Tell the user to close the browser.
$config['logout_msg'] = 'We were unable to log you out of all your sessions. To be completely sure that you are logged out, you need to close your web browser.';
}
} catch (Exception $e) {
$config['logout_msg'] = 'Failed to logout from SAML: '.$e->getMessage();
}
}
}
// Process logout.
include 'general/logoff.php';
if ($config['auth'] !== 'saml' || (bool) get_parameter('LogoutState')) {
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if ($config['auth'] == 'saml' && empty($samlid) === false) {
enterprise_hook('saml_logout', [$samlid]);
}
if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
enterprise_include_once('include/auth/saml.php');
enterprise_hook('saml_logout');
}
// Process logout.
include 'general/logoff.php';
while (@ob_end_flush()) {
// Dumping...
continue;