From 973c435138af9a94f488d3ec01d4d221854f23b8 Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 21 Dec 2022 14:38:45 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"N=C2=B05753=20-=20exposer=20l'API=20R?= =?UTF-8?q?est=20dans=20le=20SaaS=20-=20ugly=20way=20of=20passing=20API=20?= =?UTF-8?q?scope=20to=20rest.php=20during=20login"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 49748a0374a34be8c6377a8114886f88277d2503. --- webservices/rest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/webservices/rest.php b/webservices/rest.php index 199326a5b..61ab77db0 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -28,7 +28,7 @@ require_once(APPROOT.'core/restservices.class.inc.php'); /** * Result structure that is specific to the hardcoded verb 'list_operations' - */ + */ class RestResultListOperations extends RestResult { public $version; @@ -94,12 +94,12 @@ $oKPI = new ExecutionKPI(); try { utils::UseParamFile(); - + $oKPI->ComputeAndReport('Data model loaded'); - \Combodo\iTop\Application\Helper\Session::Set("ENDPOINT_CATEGORY", 'WEBSERVICE'); + $iRet = LoginWebPage::DoLogin(false, false, LoginWebPage::EXIT_RETURN); // Starting with iTop 2.2.0 portal users are no longer allowed to access the REST/JSON API $oKPI->ComputeAndReport('User login'); - + if ($iRet == LoginWebPage::EXIT_CODE_OK) { // Extra validation of the profile @@ -116,23 +116,23 @@ try case LoginWebPage::EXIT_CODE_MISSINGLOGIN: throw new Exception("Missing parameter 'auth_user'", RestResult::MISSING_AUTH_USER); break; - + case LoginWebPage::EXIT_CODE_MISSINGPASSWORD: throw new Exception("Missing parameter 'auth_pwd'", RestResult::MISSING_AUTH_PWD); break; - + case LoginWebPage::EXIT_CODE_WRONGCREDENTIALS: throw new Exception("Invalid login", RestResult::UNAUTHORIZED); break; - + case LoginWebPage::EXIT_CODE_PORTALUSERNOTAUTHORIZED: throw new Exception("Portal user is not allowed", RestResult::UNAUTHORIZED); break; - + case LoginWebPage::EXIT_CODE_NOTAUTHORIZED: throw new Exception("This user is not authorized to use the web services. (The profile REST Services User is required to access the REST web services)", RestResult::UNAUTHORIZED); break; - + default: throw new Exception("Unknown authentication error (retCode=$iRet)", RestResult::UNAUTHORIZED); } @@ -224,7 +224,7 @@ try /** @var iRestServiceProvider $oRS */ $oRS = $aOpToRestService[$sOperation]['service_provider']; $sProvider = get_class($oRS); - + CMDBObject::SetTrackOrigin('webservice-rest'); $oResult = $oRS->ExecOperation($sVersion, $sOperation, $aJsonData); } @@ -293,4 +293,4 @@ if (MetaModel::GetConfig()->Get('log_rest_service')) $oLog->SetTrim('json_output', $sResponse); $oLog->DBInsertNoReload(); -} +} \ No newline at end of file