diff --git a/core/config.class.inc.php b/core/config.class.inc.php index ec8d44b1a..51fb5a811 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1746,11 +1746,11 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], - 'security.force_login_when_no_delegated_authentication_endpoints_list' => [ + 'security.disable_exec_forced_login_for_all_enpoints' => [ 'type' => 'bool', - 'description' => 'If true, when no execution policy is defined, the user will be forced to log in (instead of being automatically logged in with the default profile)', - 'default' => false, - 'value' => false, + 'description' => 'If true, when no delegated authentication module is defined, no login will be forced on modules exec endpoints', + 'default' => true, + 'value' => true, 'source_of_value' => '', 'show_in_conf_sample' => false, ], diff --git a/pages/exec.php b/pages/exec.php index bb8e3025c..698902766 100644 --- a/pages/exec.php +++ b/pages/exec.php @@ -104,7 +104,7 @@ if ($sTargetPage === false || $sModule === 'core' || $sModule === 'dictionaries' $aModuleDelegatedAuthenticationEndpointsList = GetModuleDelegatedAuthenticationEndpoints($sModule); // If module doesn't have the delegated authentication endpoints list defined, we rely on the conf. param. to decide if we force login or not. if (is_null($aModuleDelegatedAuthenticationEndpointsList)) { - $bForceLoginWhenNoDelegatedAuthenticationEndpoints = utils::GetConfig()->Get('security.force_login_when_no_delegated_authentication_endpoints_list'); + $bForceLoginWhenNoDelegatedAuthenticationEndpoints = !utils::GetConfig()->Get('security.disable_exec_forced_login_for_all_enpoints'); if ($bForceLoginWhenNoDelegatedAuthenticationEndpoints) { require_once(APPROOT.'/application/startup.inc.php'); LoginWebPage::DoLoginEx(); diff --git a/tests/php-unit-tests/integration-tests/login-tests/LoginWebPageTest.php b/tests/php-unit-tests/integration-tests/login-tests/LoginWebPageTest.php index 1afa57ab1..45ad48d6b 100644 --- a/tests/php-unit-tests/integration-tests/login-tests/LoginWebPageTest.php +++ b/tests/php-unit-tests/integration-tests/login-tests/LoginWebPageTest.php @@ -26,14 +26,14 @@ class LoginWebPageTest extends ItopDataTestCase $this->BackupConfiguration(); $sFolderPath = APPROOT.'env-production/extension-with-delegated-authentication-endpoints-list'; if (file_exists($sFolderPath)) { - throw new Exception("Folder $sFolderPath already exists, please remove it before running the test"); + $this->RecurseRmdir($sFolderPath); } mkdir($sFolderPath); $this->RecurseCopy(__DIR__.'/extension-with-delegated-authentication-endpoints-list', $sFolderPath); $sFolderPath = APPROOT.'env-production/extension-without-delegated-authentication-endpoints-list'; if (file_exists($sFolderPath)) { - throw new Exception("Folder $sFolderPath already exists, please remove it before running the test"); + $this->RecurseRmdir($sFolderPath); } mkdir($sFolderPath); $this->RecurseCopy(__DIR__.'/extension-without-delegated-authentication-endpoints-list', $sFolderPath); @@ -81,8 +81,7 @@ class LoginWebPageTest extends ItopDataTestCase public function testUserCanAccessAnyFile() { - // generate random login - $sUserLogin = 'user-'.date('YmdHis'); + $sUserLogin = 'user-'.uniqid(); $this->CreateUser($sUserLogin, self::$aURP_Profiles['Service Desk Agent'], self::PASSWORD); $this->GivenConfigFileAllowedLoginTypes(explode('|', 'form')); @@ -102,7 +101,7 @@ class LoginWebPageTest extends ItopDataTestCase public function testWithoutDelegatedAuthenticationEndpointsListWithForceLoginConf() { @chmod($this->oConfig->GetLoadedFile(), 0770); - $this->oConfig->Set('security.force_login_when_no_delegated_authentication_endpoints_list', true, 'AnythingButEmptyOrUnknownValue'); // 3rd param to write file even if show_in_conf_sample is false + $this->oConfig->Set('security.disable_exec_forced_login_for_all_enpoints', false, 'AnythingButEmptyOrUnknownValue'); // 3rd param to write file even if show_in_conf_sample is false $this->oConfig->WriteToFile(); @chmod($this->oConfig->GetLoadedFile(), 0444); $sPageContent = $this->CallItopUri(