ComputeAndReport("Session Start"); $sEnvFullPath = APPROOT.'env-'.$sEnvironment; $sPageRelativePath = $sModule.'/'.$sPage; $sPageEnvFullPath = $sEnvFullPath.'/'.$sPageRelativePath; if (is_link($sPageEnvFullPath)) { $oConfig = utils::GetConfig(); $sSourceDir = $oConfig->Get('source_dir'); // generated at compile time, works for legacy build with datamodels/1.x // in case module was compiled to symlink, we need to check against real linked path as symlink is resolved $aPossibleBasePaths = [ APPROOT.$sSourceDir, APPROOT.'extensions', APPROOT.'data/'.$sEnvironment.'-modules', APPROOT.'data/downloaded-extensions', // Hub connector ]; } else { $aPossibleBasePaths = [$sEnvFullPath]; } $sTargetPage = CheckPageExists($sPageEnvFullPath, $aPossibleBasePaths); if ($sTargetPage === false) { // Do not recall the page parameters (security takes precedence) echo "Wrong module, page name or environment..."; exit; } ///////////////////////////////////////// // // GO! // // check module white list // check conf param // force login if needed $aModuleDelegatedAuthenticationEndpointsList = GetModuleDelegatedAuthenticationEndpoints($sModule); if (is_null($aModuleDelegatedAuthenticationEndpointsList)) { $bForceLoginWhenNoDelegatedAuthenticationEndpoints = utils::GetConfig()->Get('security.force_login_when_no_delegated_authentication_endpoints_list'); if ($bForceLoginWhenNoDelegatedAuthenticationEndpoints) { require_once(APPROOT.'/application/startup.inc.php'); LoginWebPage::DoLoginEx(); } } if (is_array($aModuleDelegatedAuthenticationEndpointsList) && !in_array($sPage, $aModuleDelegatedAuthenticationEndpointsList)) { // if module defined a delegated authentication endpoints but not for the current page, we consider that the page is not allowed to be executed without login require_once(APPROOT.'/application/startup.inc.php'); LoginWebPage::DoLoginEx(); } if (is_null($aModuleDelegatedAuthenticationEndpointsList) && !UserRights::IsLoggedIn()) { // check if user is not logged in, if not log a warning in the log file as the page is executed without login, which is not recommended for security reason IssueLog::Warning("The page '$sPage' is executed without login. In the future, this call will be blocked, and will likely cause unwanted behavior in the module '$sModule'. \n Please define a delegated authentication endpoints for the module as described in https://www.itophub.io/wiki/page?id=latest:customization:new_extension#security."); } require_once($sTargetPage); function GetModuleDelegatedAuthenticationEndpoints(string $sModuleName): ?array { $sModuleFile = utils::GetAbsoluteModulePath($sModuleName).'/module.'.$sModuleName.'.php'; require_once APPROOT.'setup/extensionsmap.class.inc.php'; $oExtensionMap = new iTopExtensionsMap(); $aModuleParam = $oExtensionMap->GetModuleInfo($sModuleFile)[2]; return $aModuleParam['delegated_authentication_endpoints'] ?? null; }