N°2311 - Debug login FSM

This commit is contained in:
Eric
2019-08-14 09:13:03 +02:00
parent 7885d712a6
commit 11f62063a6
7 changed files with 43 additions and 4 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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)

View File

@@ -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
*/

View File

@@ -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',