From 11f62063a6d327d1438ff0c68b03f7a57fe65536 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 14 Aug 2019 09:13:03 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02311=20-=20Debug=20login=20FSM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/loginbasic.class.inc.php | 1 - application/loginexternal.class.inc.php | 1 - application/loginform.class.inc.php | 1 - application/loginurl.class.inc.php | 1 - application/loginwebpage.class.inc.php | 20 ++++++++++++++++++++ application/utils.inc.php | 14 ++++++++++++++ core/config.class.inc.php | 9 +++++++++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/application/loginbasic.class.inc.php b/application/loginbasic.class.inc.php index 0fe1cfac8..056b140fe 100644 --- a/application/loginbasic.class.inc.php +++ b/application/loginbasic.class.inc.php @@ -50,7 +50,6 @@ class LoginBasic implements iLoginFSMExtension if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal')) { $iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS; - return LoginWebPage::LOGIN_FSM_RETURN_ERROR; } } diff --git a/application/loginexternal.class.inc.php b/application/loginexternal.class.inc.php index e918c3354..65da5bf94 100644 --- a/application/loginexternal.class.inc.php +++ b/application/loginexternal.class.inc.php @@ -59,7 +59,6 @@ class LoginExternal implements iLoginFSMExtension if (!UserRights::CheckCredentials($sAuthUser, '', $_SESSION['login_mode'], 'external')) { $iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS; - return LoginWebPage::LOGIN_FSM_RETURN_ERROR; } } diff --git a/application/loginform.class.inc.php b/application/loginform.class.inc.php index 819bd5b17..f81bde0bd 100644 --- a/application/loginform.class.inc.php +++ b/application/loginform.class.inc.php @@ -75,7 +75,6 @@ class LoginForm implements iLoginFSMExtension if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal')) { $iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS; - return LoginWebPage::LOGIN_FSM_RETURN_ERROR; } } diff --git a/application/loginurl.class.inc.php b/application/loginurl.class.inc.php index 040b75360..f513f4ecd 100644 --- a/application/loginurl.class.inc.php +++ b/application/loginurl.class.inc.php @@ -65,7 +65,6 @@ class LoginURL implements iLoginFSMExtension if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal')) { $iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS; - return LoginWebPage::LOGIN_FSM_RETURN_ERROR; } } diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index bb22a1c0d..b0d5403bd 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -503,6 +503,7 @@ EOF // Non secured URL... request for a secure connection throw new Exception('Secure connection required!'); } + $bLoginDebug = MetaModel::GetConfig()->Get('login_debug'); if (!isset($_SESSION['login_state']) || ($_SESSION['login_state'] == self::LOGIN_STATE_ERROR)) { @@ -510,6 +511,15 @@ EOF } $sLoginState = $_SESSION['login_state']; + $sSessionLog = ''; + if ($bLoginDebug) + { + IssueLog::Info("---------------------------------"); + IssueLog::Info("--> Entering Login FSM with state: [$sLoginState]"); + $sSessionLog = session_id().' '.utils::GetSessionLog(); + IssueLog::Info("SESSION: $sSessionLog"); + } + // Finite state machine loop while (true) { @@ -524,6 +534,16 @@ EOF /** @var iLoginFSMExtension $oLoginFSMExtensionInstance */ foreach ($aLoginPlugins as $oLoginFSMExtensionInstance) { + if ($bLoginDebug) + { + $sCurrSessionLog = session_id().' '.utils::GetSessionLog(); + if ($sCurrSessionLog != $sSessionLog) + { + $sSessionLog = $sCurrSessionLog; + IssueLog::Info("SESSION: $sSessionLog"); + } + IssueLog::Info("Login: state: [$sLoginState] call: ".get_class($oLoginFSMExtensionInstance)); + } $iErrorCode = self::EXIT_CODE_OK; $iResponse = $oLoginFSMExtensionInstance->LoginAction($sLoginState, $iErrorCode); if ($iResponse == self::LOGIN_FSM_RETURN_OK) diff --git a/application/utils.inc.php b/application/utils.inc.php index 1b39d5aa0..33d4a043c 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -890,6 +890,20 @@ class utils return (isset($_SESSION['can_logoff']) ? $_SESSION['can_logoff'] : false); } + /** + * Get the _SESSION variable for logging purpose + * @return false|string + */ + public static function GetSessionLog() + { + ob_start(); + print_r($_SESSION); + $sSessionLog = ob_get_contents(); + ob_end_clean(); + + return $sSessionLog; + } + /** * Initializes the CAS client */ diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 3e3e75e53..3d2a59467 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -680,6 +680,15 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ), + 'login_debug' => array( + 'type' => 'bool', + 'description' => 'Activate the login FSM debug', + // examples... not used (nor 'description') + 'default' => false, + 'value' => false, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ), 'forgot_password' => array( 'type' => 'bool', 'description' => 'Enable the "Forgot password" feature',