trick to avoid simplesamlphp logout bug while using custom session handlers

This commit is contained in:
fbsanchez 2020-10-19 18:45:40 +02:00
parent 987e77271e
commit 92211c71b7
1 changed files with 17 additions and 20 deletions

View File

@ -273,6 +273,7 @@ if (strlen($search) > 0) {
} }
// Login process. // Login process.
enterprise_include_once('include/auth/saml.php');
if (! isset($config['id_user'])) { if (! isset($config['id_user'])) {
// Clear error messages. // Clear error messages.
unset($_COOKIE['errormsg']); unset($_COOKIE['errormsg']);
@ -395,7 +396,6 @@ if (! isset($config['id_user'])) {
$nick_in_db = $_SESSION['prepared_login_da']['id_user']; $nick_in_db = $_SESSION['prepared_login_da']['id_user'];
$expired_pass = false; $expired_pass = false;
} else if (($config['auth'] == 'saml') && ($login_button_saml)) { } else if (($config['auth'] == 'saml') && ($login_button_saml)) {
enterprise_include_once('include/auth/saml.php');
$saml_user_id = enterprise_hook('saml_process_user_login'); $saml_user_id = enterprise_hook('saml_process_user_login');
if (!$saml_user_id) { if (!$saml_user_id) {
include_once 'general/noaccesssaml.php'; include_once 'general/noaccesssaml.php';
@ -404,18 +404,14 @@ if (! isset($config['id_user'])) {
$nick_in_db = $saml_user_id; $nick_in_db = $saml_user_id;
if (!$nick_in_db) { if (!$nick_in_db) {
if ($config['auth'] !== 'saml' || (bool) get_parameter('LogoutState')) { if ($config['auth'] === 'saml') {
$_SESSION = []; enterprise_hook('saml_logout');
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
} }
if ($config['auth'] === 'saml') { $_SESSION = [];
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; session_destroy();
enterprise_include_once('include/auth/saml.php'); header_remove('Set-Cookie');
enterprise_hook('saml_logout', [$samlid]); setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
// Process logout. // Process logout.
include 'general/logoff.php'; include 'general/logoff.php';
@ -956,6 +952,10 @@ if (! isset($config['id_user'])) {
} }
exit('</html>'); exit('</html>');
} else {
if ($config['auth'] === 'saml') {
enterprise_hook('saml_login_status_verifier');
}
} }
} }
} }
@ -969,19 +969,16 @@ if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) {
if (isset($_GET['bye'])) { if (isset($_GET['bye'])) {
$iduser = $_SESSION['id_usuario']; $iduser = $_SESSION['id_usuario'];
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') { if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
enterprise_include_once('include/auth/saml.php');
enterprise_hook('saml_logout'); enterprise_hook('saml_logout');
} }
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
// Process logout. // Process logout.
include 'general/logoff.php'; include 'general/logoff.php';