Upgrade code - step 1

This commit is contained in:
Fernando Ontiveros
2025-03-27 12:06:06 +00:00
parent fbd92c5964
commit 7f3ee186de
47635 changed files with 5941896 additions and 1779 deletions

View File

@@ -2,6 +2,7 @@
namespace Maveriks\Extension;
use Luracast\Restler\Defaults;
use Luracast\Restler\Scope;
use Luracast\Restler\Format\JsonFormat;
use Luracast\Restler\Format\UrlEncodedFormat;
use ProcessMaker\Plugins\PluginRegistry;
@@ -199,4 +200,49 @@ class Restler extends \Luracast\Restler\Restler
return $object;
}
/**
* Overrides original method because the behaviour was changed in the last version of Restler
*
* Ref.- https://github.com/Luracast/Restler/commit/bd1b95a52fed98ac10bf8db4a2924bcd14cfd7db
*/
protected function authenticate()
{
$o = & $this->apiMethodInfo;
$accessLevel = max(Defaults::$apiAccessLevel,
$o->accessLevel);
try {
if ($accessLevel || count($this->postAuthFilterClasses)) {
$this->dispatch('authenticate');
if (!count($this->authClasses)) {
throw new RestException(
403,
'at least one Authentication Class is required'
);
}
foreach ($this->authClasses as $authClass) {
$authObj = Scope::get($authClass);
if (!method_exists($authObj,
Defaults::$authenticationMethod)
) {
throw new RestException (
500, 'Authentication Class ' .
'should implement iAuthenticate');
} elseif (
!$authObj->{Defaults::$authenticationMethod}()
) {
throw new RestException(401);
}
}
$this->authenticated = true;
}
$this->authVerified = true;
} catch (RestException $e) {
$this->authVerified = true;
if ($accessLevel > 1) { //when it is not a hybrid api
throw ($e);
} else {
$this->authenticated = false;
}
}
}
}

View File

@@ -6,6 +6,7 @@ use Bootstrap;
use Exception;
use G;
use Illuminate\Foundation\Http\Kernel;
use Luracast\Restler\Defaults;
use Luracast\Restler\Format\UploadFormat;
use Luracast\Restler\RestException;
use Maveriks\Util;
@@ -169,6 +170,7 @@ class WebApplication
$uri = '/' . implode('/', $uriTemp);
$this->loadEnvironment($workspace);
Defaults::$smartParameterParsing = false;
$this->dispatchApiRequest($uri, $version = "1.0");
break;
}
@@ -299,7 +301,7 @@ class WebApplication
$sysConfig = System::getSystemConfiguration();
\Luracast\Restler\Defaults::$cacheDirectory = $cacheDir;
Defaults::$cacheDirectory = $cacheDir;
$productionMode = (bool) !(isset($sysConfig["service_api_debug"]) && $sysConfig["service_api_debug"]);
Util\Logger::log("Serving API mode: " . ($productionMode ? "production" : "development"));