From 73d67763c9b610af79043f0dfbf9a015c2b6a5f9 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 1 Jul 2020 14:57:20 +0300 Subject: [PATCH] dev --- application/Espo/Core/Application.php | 129 ++++- application/Espo/Core/Utils/Api/Auth.php | 152 +++--- application/Espo/Core/Utils/Api/Output.php | 20 +- application/Espo/Core/Utils/Auth.php | 36 +- .../Espo/Core/Utils/Authentication/Hmac.php | 2 +- application/Espo/Core/Utils/Route.php | 27 +- .../metadata/app/containerServices.json | 6 - composer.json | 4 +- composer.lock | 451 ++++++++++++++++-- install/core/Installer.php | 3 +- 10 files changed, 662 insertions(+), 168 deletions(-) diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php index 242e7c4a83..33ed4427c2 100644 --- a/application/Espo/Core/Application.php +++ b/application/Espo/Core/Application.php @@ -39,6 +39,7 @@ use Espo\Core\{ CronManager, Utils\Auth, Utils\Api\Auth as ApiAuth, + Api\Output as ApiOutput, Utils\Route, Utils\Autoload, Portal\Application as PortalApplication, @@ -49,6 +50,13 @@ use Espo\Core\{ Loaders\Metadata as MetadataLoader, }; +use Psr\Http\Message\{ + ResponseInterface as Response, + ServerRequestInterface as Request, +}; + +use Slim\Factory\AppFactory as SlimAppFactory; + /** * The main entry point of the application. */ @@ -56,6 +64,8 @@ class Application { protected $container; + protected $slim = null; + protected $loaderClassNames = [ 'config' => ConfigLoader::class, 'log' => LogLoader::class, @@ -83,7 +93,7 @@ class Application */ public function run(string $name = 'default') { - $this->routeHooks(); + //$this->routeHooks(); $this->initRoutes(); $this->getSlim()->run(); } @@ -127,8 +137,9 @@ class Application exit; } } - $auth = new Auth($this->container, $authNotStrict); - $apiAuth = new ApiAuth($auth, $authRequired, true); + $auth = $this->createAuth($request, true); + $apiAuth = new ApiAuth($auth, $authRequired, true, true); + $slim->add($apiAuth); $request = $slim->request(); @@ -155,8 +166,7 @@ class Application return; } - $auth = $this->createAuth(); - $auth->useNoAuth(); + $this->setupSystemUser(); $cronManager = $this->container->get('cronManager'); $cronManager->run(); @@ -211,8 +221,7 @@ class Application */ public function runJob(string $id) { - $auth = $this->createAuth(); - $auth->useNoAuth(); + $this->setupSystemUser(); $cronManager = $this->container->get('cronManager'); $cronManager->runJobById($id); @@ -241,8 +250,7 @@ class Application */ public function runCommand(string $command) { - $auth = $this->createAuth(); - $auth->useNoAuth(); + $this->setupSystemUser(); $consoleCommandManager = $this->container->get('consoleCommandManager'); return $consoleCommandManager->run($command); @@ -272,7 +280,11 @@ class Application protected function getSlim() { - return $this->container->get('slim'); + if (!$this->slim) { + $this->slim = SlimAppFactory::create(); + $this->slim->setBasePath(Route::detectBasePath()); + } + return $this->slim; } protected function getMetadata() @@ -285,9 +297,9 @@ class Application return $this->container->get('config'); } - protected function createAuth() + protected function createAuth(Request $request, bool $allowAnyAccess = false) : Auth { - return new Auth($this->container); + return new Auth($this->container, $request, $allowAnyAccess); } protected function createApiAuth(Auth $auth) : ApiAuth @@ -311,11 +323,11 @@ class Application $this->getSlim()->add($apiAuth); $this->getSlim()->hook('slim.before.dispatch', function () use ($slim, $container) { - $route = $slim->router()->getCurrentRoute(); + /*$route = $slim->router()->getCurrentRoute(); $conditions = $route->getConditions(); $response = $slim->response(); - $response->headers->set('Content-Type', 'application/json'); + $response->headers->set('Content-Type', 'application/json');*/ $routeOptions = call_user_func($route->getCallable()); $routeKeys = is_array($routeOptions) ? array_keys($routeOptions) : []; @@ -385,6 +397,10 @@ class Application { $crudList = array_keys($this->getConfig()->get('crud')); + $slim = $this->getSlim(); + + $slim->addRoutingMiddleware(); + foreach ($this->getRouteList() as $route) { $method = strtolower($route['method']); if (!in_array($method, $crudList) && $method !== 'options') { @@ -394,14 +410,82 @@ class Application continue; } - $currentRoute = $this->getSlim()->$method($route['route'], function() use ($route) { - return $route['params']; - }); + $currentRoute = $slim-> + $method( + $route['route'], + function (Request $request, Response $response, $args) use ($route) { + $authRequired = true; - if (isset($route['conditions'])) { - $currentRoute->conditions($route['conditions']); + $conditions = $route['conditions'] ?? []; + if (($conditions['auth'] ?? true) === false) { + $authRequired = false; + } + + print_r($args); + die; + + $auth = $this->createAuth($request); + $apiAuth = new ApiAuth($auth, $authRequired); + + $response = $apiAuth->process($request, $response); + + if (!$apiAuth->isResolved()) { + return $response; + } + + if ($apiAuth->isResolvedUseNoAuth()) { + $this->setupSystemUser(); + } + + $response = $this->processRoute($route, $request, $response, $args); + + return $response; + } + ); + } + } + + protected function processRoute(array $route, Request $request, Response $response, array $args) + { + $response = $response->withHeader('Content-Type', 'application/json'); + + $data = (string) $request->getBody(); + + $params = []; + + $paramKeys = array_keys($route['params']); + + foreach ($paramKeys as $key) { + $paramName = $key; + if ($key[0] === ':') { + $paramName = substr($key, 1); + $params[$paramName] = $args[$paramName]; + } else { + $params[$paramName] = $route['params'][$key] } } + + $controllerName = $params['controller'] ?? $args['controller'] ?? null; + $actionName = $params['action'] ?? $args['action'] ?? null; + + if (!$controllerName) { + throw new Error("Route ".$route['route']." doesn't have a controller."); + } + + if (!$actionName) { + $httpMethod = strtolower($request->getMethod()); + $crudList = $this->getConfig()->get('crud') ?? []; + $actionName = $crudList[$httpMethod] ?? null; + if (!$actionName) { + throw new Error("No action for method {$httpMethod}."); + } + } + + + unset($params['controller']); + unset($params['action']); + + return $response; } protected function initAutoloads() @@ -452,7 +536,14 @@ class Application public function setupSystemUser() { $user = $this->container->get('entityManager')->getEntity('User', 'system'); + if (!$user) { + throw new Error("System user is not found"); + } + + $user->set('ipAddress', $_SERVER['REMOTE_ADDR'] ?? null); $user->set('type', 'system'); + $this->container->set('user', $user); } + } diff --git a/application/Espo/Core/Utils/Api/Auth.php b/application/Espo/Core/Utils/Api/Auth.php index 82efc14baa..c0735259fc 100644 --- a/application/Espo/Core/Utils/Api/Auth.php +++ b/application/Espo/Core/Utils/Api/Auth.php @@ -29,11 +29,14 @@ namespace Espo\Core\Utils\Api; -use \Espo\Core\Utils\Api\Slim; +use Espo\Core\Utils\Auth as AuthUtil; -use \Espo\Core\Utils\Auth as AuthUtil; +use Psr\Http\Message\{ + ServerRequestInterface as Request, + ResponseInterface as Response, +}; -class Auth extends \Slim\Middleware +class Auth { protected $auth; @@ -41,35 +44,59 @@ class Auth extends \Slim\Middleware protected $showDialog = false; - public function __construct(AuthUtil $auth, $authRequired = null, $showDialog = false) + private $isResolved = false; + + private $isResolvedUseNoAuth = false; + + public function __construct(AuthUtil $auth, bool $authRequired = null, bool $isEntryPoint = false, bool $showDialog = false) { $this->auth = $auth; $this->authRequired = $authRequired; + $this->isEntryPoint = $isEntryPoint; $this->showDialog = $showDialog; } - function call() + protected function resolve() { - $request = $this->app->request(); + $this->resolved = true; + } - $uri = $request->getResourceUri(); + protected function resolveUseNoAuth() + { + $this->isResolvedUseNoAuth = true; + } + + public function isResolved() : bool + { + return $this->isResolved; + } + + public function isResolvedUseNoAuth() : bool + { + return $this->isResolvedUseNoAuth; + } + + public function process(Request $request, Response $response) : Response + { + $uri = $request->getUri(); $httpMethod = $request->getMethod(); - $username = $request->headers->get('PHP_AUTH_USER'); - $password = $request->headers->get('PHP_AUTH_PW'); + $username = $request->getHeaderLine('PHP_AUTH_USER'); + $password = $request->getHeaderLine('PHP_AUTH_PW'); $authenticationMethod = null; - $espoAuthorizationHeader = $request->headers->get('Http-Espo-Authorization'); + $espoAuthorizationHeader = $request->getHeaderLine('Http-Espo-Authorization'); + if (isset($espoAuthorizationHeader)) { list($username, $password) = explode(':', base64_decode($espoAuthorizationHeader), 2); } else { - $hmacAuthorizationHeader = $request->headers->get('X-Hmac-Authorization'); + $hmacAuthorizationHeader = $request->getHeaderLine('X-Hmac-Authorization'); if ($hmacAuthorizationHeader) { $authenticationMethod = 'Hmac'; list($username, $password) = explode(':', base64_decode($hmacAuthorizationHeader), 2); } else { - $apiKeyHeader = $request->headers->get('X-Api-Key'); + $apiKeyHeader = $request->getHeaderLine('X-Api-Key'); if ($apiKeyHeader) { $authenticationMethod = 'ApiKey'; $username = $apiKeyHeader; @@ -86,83 +113,67 @@ class Auth extends \Slim\Middleware } if (!isset($username) && !isset($password)) { - $espoCgiAuth = $request->headers->get('Http-Espo-Cgi-Auth'); + $espoCgiAuth = $request->getHeaderLine('Http-Espo-Cgi-Auth'); if (empty($espoCgiAuth)) { - $espoCgiAuth = $request->headers->get('Redirect-Http-Espo-Cgi-Auth'); + $espoCgiAuth = $request->getHeaderLine('Redirect-Http-Espo-Cgi-Auth'); } if (!empty($espoCgiAuth)) { list($username, $password) = explode(':' , base64_decode(substr($espoCgiAuth, 6))); } } - if (is_null($this->authRequired)) { - $routes = $this->app->router()->getMatchedRoutes($httpMethod, $uri); - - if (!empty($routes[0])) { - $routeConditions = $routes[0]->getConditions(); - if (isset($routeConditions['auth']) && $routeConditions['auth'] === false) { - - if ($username && $password) { - try { - $isAuthenticated = $this->auth->login($username, $password); - } catch (\Exception $e) { - $this->processException($e); - return; - } - if ($isAuthenticated) { - $this->next->call(); - return; - } + if (!$this->authRequired) { + if (!$this->isEntryPoint) { + if ($username && $password) { + try { + $isAuthenticated = $this->auth->login($username, $password); + } catch (\Exception $e) { + return $this->processException($response, $e); + } + if ($isAuthenticated) { + $this->resolve(); + return $response; } - - $this->auth->useNoAuth(); - $this->next->call(); - return; } } - } else { - if (!$this->authRequired) { - $this->auth->useNoAuth(); - $this->next->call(); - return; - } + $this->resolveUseNoAuth(); + return $response; } if ($username) { try { $authResult = $this->auth->login($username, $password, $authenticationMethod); } catch (\Exception $e) { - $this->processException($e); - return; + return $this->processException($response, $e); } if ($authResult) { - $this->handleAuthResult($authResult); + $response = $this->handleAuthResult($response, $authResult); } else { - $this->processUnauthorized(); + $response = $this->processUnauthorized($response); } } else { - if (!$this->isXMLHttpRequest()) { + if (!$this->isXMLHttpRequest($request)) { $this->showDialog = true; } - $this->processUnauthorized(); + $response = $this->processUnauthorized($response); } + + return $response; } - protected function handleAuthResult(array $authResult) + protected function handleAuthResult(Response $response, array $authResult) : Response { $status = $authResult['status']; - $response = $this->app->response(); - if ($status === AuthUtil::STATUS_SUCCESS) { - $this->next->call(); - return; + $this->resolve(); + return $response; } if ($status === AuthUtil::STATUS_SECOND_STEP_REQUIRED) { - $response->setStatus(401); - $response->headers->set('X-Status-Reason', 'second-step-required'); + $response = $response->withStatus(401); + $response = $response->withHeader('X-Status-Reason', 'second-step-required'); $bodyData = [ 'status' => $status, @@ -170,36 +181,35 @@ class Auth extends \Slim\Middleware 'view' => $authResult['view'] ?? null, 'token' => $authResult['token'] ?? null, ]; - $response->setBody(json_encode($bodyData)); + $response->getBody()->write(json_encode($bodyData)); } + + return $response; } - protected function processException(\Exception $e) + protected function processException(Response $response, \Exception $e) : Response { - $response = $this->app->response(); + $reason = $e->getMessage(); - if ($e->getMessage()) { - $response->headers->set('X-Status-Reason', $e->getMessage()); + if ($reason) { + $response = $response->withHeader('X-Status-Reason', $e->getMessage()); } - $response->setStatus($e->getCode()); + + return $response->withStatus($e->getCode(), $reason); } - protected function processUnauthorized() + protected function processUnauthorized(Response $response) : Response { - $response = $this->app->response(); - if ($this->showDialog) { - $response->headers->set('WWW-Authenticate', 'Basic realm=""'); + $response = $response->withHeader('WWW-Authenticate', 'Basic realm=""'); } - $response->setStatus(401); + + return $response->withStatus(401); } - protected function isXMLHttpRequest() + protected function isXMLHttpRequest(Request $request) { - $request = $this->app->request(); - - $httpXRequestedWith = $request->headers->get('Http-X-Requested-With'); - if ($httpXRequestedWith && strtolower($httpXRequestedWith) == 'xmlhttprequest') { + if (strtolower($request->getHeaderLine('Http-X-Requested-With') ?? '') == 'xmlhttprequest') { return true; } diff --git a/application/Espo/Core/Utils/Api/Output.php b/application/Espo/Core/Utils/Api/Output.php index cbe98d88dd..eef25cba99 100644 --- a/application/Espo/Core/Utils/Api/Output.php +++ b/application/Espo/Core/Utils/Api/Output.php @@ -31,8 +31,6 @@ namespace Espo\Core\Utils\Api; class Output { - private $slim; - protected $errorDescriptions = [ 400 => 'Bad Request', 401 => 'Unauthorized', @@ -50,14 +48,8 @@ class Output 'PDOException', ]; - public function __construct(Slim $slim) + public function __construct() { - $this->slim = $slim; - } - - protected function getSlim() - { - return $this->slim; } public function render($data = null) @@ -71,8 +63,9 @@ class Output echo $data; } - public function processError(string $message = 'Error', $statusCode = 500, bool $toPrint = false, $exception = null) - { + public function processError( + string $message = 'Error', int $statusCode = 500, bool $toPrint = false, $exception = null + ) : Response { $currentRoute = $this->getSlim()->router()->getCurrentRoute(); if (isset($currentRoute)) { @@ -99,7 +92,7 @@ class Output $this->displayError($message, $statusCode, $toPrint, $exception); } - public function displayError(string $text, $statusCode = 500, bool $toPrint = false, $exception = null) + protected function displayError(string $text, $statusCode = 500, bool $toPrint = false, $exception = null) { $logLevel = 'error'; $messageLineFile = null; @@ -155,7 +148,8 @@ class Output $this->getSlim()->stop(); } else { - $GLOBALS['log']->info('Could not get Slim instance. It looks like a direct call (bypass API). URL: '.$_SERVER['REQUEST_URI']); + $GLOBALS['log']->info( + 'Could not get Slim instance. It looks like a direct call (bypass API). URL: '.$_SERVER['REQUEST_URI']); die($text); } } diff --git a/application/Espo/Core/Utils/Auth.php b/application/Espo/Core/Utils/Auth.php index ef35f6aee4..ef44824d9b 100644 --- a/application/Espo/Core/Utils/Auth.php +++ b/application/Espo/Core/Utils/Auth.php @@ -44,6 +44,10 @@ use Espo\Core\Utils\Authentication\TwoFA\CodeInterface as TwoFACodeInterface; use Espo\Core\Container; +use Psr\Http\Message\{ + ServerRequestInterface as Request, +}; + /** * Handles authentication. The entry point of the auth process. */ @@ -67,15 +71,13 @@ class Auth const STATUS_SECOND_STEP_REQUIRED = 'secondStepRequired'; - protected $container; + protected $container; - public function __construct(Container $container, bool $allowAnyAccess = false) + public function __construct(Container $container, Request $request, bool $allowAnyAccess = false) { $this->container = $container; - + $this->request = $request; $this->allowAnyAccess = $allowAnyAccess; - - $this->request = $container->get('slim')->request(); } protected function getContainer() @@ -134,31 +136,17 @@ class Auth return $this->getContainer()->get('metadata'); } - public function useNoAuth() - { - $entityManager = $this->getContainer()->get('entityManager'); - - $user = $entityManager->getRepository('User')->get('system'); - if (!$user) { - throw new Error("System user is not found"); - } - - $user->set('ipAddress', $_SERVER['REMOTE_ADDR'] ?? null); - - $this->getContainer()->set('user', $user); - } - public function login(string $username, ?string $password = null, ?string $authenticationMethod = null) : ?array { $isByTokenOnly = false; if (!$authenticationMethod) { - if ($this->request->headers->get('Http-Espo-Authorization-By-Token') === 'true') { + if ($this->request->getHeaderLine('Http-Espo-Authorization-By-Token') === 'true') { $isByTokenOnly = true; } } - $createTokenSecret = $this->request->headers->get('Espo-Authorization-Create-Token-Secret') === 'true'; + $createTokenSecret = $this->request->getHeaderLine('Espo-Authorization-Create-Token-Secret') === 'true'; if ($createTokenSecret) { if ($this->getConfig()->get('authTokenSecretDisabled')) { @@ -288,7 +276,7 @@ class Auth if ($twoFAMethod) { $twoFAImpl = $this->get2FAImpl($twoFAMethod); - $twoFACode = $this->request->headers->get('Espo-Authorization-Code'); + $twoFACode = $this->request->getHeaderLine('Espo-Authorization-Code'); if ($twoFACode) { if (!$twoFAImpl->verifyCode($user, $twoFACode)) { @@ -305,7 +293,7 @@ class Auth $secondStepRequired = $loginResultData['secondStepRequired'] ?? false; } - if (!$secondStepRequired && $this->request->headers->get('Http-Espo-Authorization')) { + if (!$secondStepRequired && $this->request->getHeaderLine('Http-Espo-Authorization')) { if (!$authToken) { $authToken = $this->getEntityManager()->getEntity('AuthToken'); $token = $this->generateToken(); @@ -461,7 +449,7 @@ class Auth 'ipAddress' => $_SERVER['REMOTE_ADDR'] ?? null, 'requestTime' => $_SERVER['REQUEST_TIME_FLOAT'], 'requestMethod' => $this->request->getMethod(), - 'requestUrl' => $this->request->getUrl() . $this->request->getPath(), + 'requestUrl' => $this->request->getUri() . $this->request->getPath(), 'authenticationMethod' => $authenticationMethod ]); diff --git a/application/Espo/Core/Utils/Authentication/Hmac.php b/application/Espo/Core/Utils/Authentication/Hmac.php index 3644c5396d..4db17632d7 100644 --- a/application/Espo/Core/Utils/Authentication/Hmac.php +++ b/application/Espo/Core/Utils/Authentication/Hmac.php @@ -55,7 +55,7 @@ class Hmac extends Base $secretKey = $apiKeyUtil->getSecretKeyForUserId($user->id); if (!$secretKey) return; - $string = $request->getMethod() . ' ' . $request->getResourceUri(); + $string = $request->getMethod() . ' ' . $request->getUri(); if ($hash === \Espo\Core\Utils\ApiKey::hash($secretKey, $string)) { return $user; diff --git a/application/Espo/Core/Utils/Route.php b/application/Espo/Core/Utils/Route.php index bfbf7485e4..1a80f5c633 100644 --- a/application/Espo/Core/Utils/Route.php +++ b/application/Espo/Core/Utils/Route.php @@ -169,20 +169,41 @@ class Route } /** - * Check and adjust the route path + * Check and adjust the route path. * * @param string $routePath - it can be "/App/user", "App/user" * * @return string - "/App/user" */ - protected function adjustPath($routePath) + protected function adjustPath(string $routePath) : string { $routePath = trim($routePath); - if (substr($routePath,0,1) != '/') { + // to fast route format + $routePath = preg_replace('/\:([a-zA-Z0-9]+)/', '{${1}}', $routePath); + + if (substr($routePath, 0, 1) != '/') { return '/'.$routePath; } return $routePath; } + + public static function detectBasePath() : string + { + $scriptName = parse_url($_SERVER['SCRIPT_NAME'] , PHP_URL_PATH); + $scriptDir = dirname($scriptName); + + $uri = parse_url('http://any.com' . $_SERVER['REQUEST_URI'], PHP_URL_PATH); + + $basePath = ''; + + if (stripos($uri, $scriptName) === 0) { + $basePath = $scriptName; + } elseif ($scriptDir !== '/' && stripos($uri, $scriptDir) === 0) { + $basePath = $scriptDir; + } + + return $basePath; + } } \ No newline at end of file diff --git a/application/Espo/Resources/metadata/app/containerServices.json b/application/Espo/Resources/metadata/app/containerServices.json index 56a8abdbe0..4d4f403508 100644 --- a/application/Espo/Resources/metadata/app/containerServices.json +++ b/application/Espo/Resources/metadata/app/containerServices.json @@ -1,10 +1,4 @@ { - "slim": { - "className": "Espo\\Core\\Utils\\Api\\Slim" - }, - "output": { - "className": "Espo\\Core\\Utils\\Api\\Output" - }, "schema": { "className": "Espo\\Core\\Utils\\Database\\Schema\\Schema" }, diff --git a/composer.json b/composer.json index 63b42e9d6a..87cb13ece5 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,9 @@ "ext-curl": "*", "ext-exif": "*", "doctrine/dbal": "2.*", - "slim/slim": "2.6.2", + "slim/slim": "4.5.*", + "slim/psr7": "*", + "psr/log": "1.1.*", "mtdowling/cron-expression": "1.0.*", "laminas/laminas-mail": "2.10.0", "laminas/laminas-ldap": "2.*", diff --git a/composer.lock b/composer.lock index 12608a27eb..38cb334b10 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f392949a4845522838597d0a5d5c8cb1", + "content-hash": "c581826c89ac8f6b8d1c708cf83f77f1", "packages": [ { "name": "cboden/ratchet", @@ -667,6 +667,58 @@ ], "time": "2017-07-23T21:35:13+00:00" }, + { + "name": "fig/http-message-util", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "3242caa9da7221a304b8f84eb9eaddae0a7cf422" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/3242caa9da7221a304b8f84eb9eaddae0a7cf422", + "reference": "3242caa9da7221a304b8f84eb9eaddae0a7cf422", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0" + }, + "suggest": { + "psr/http-message": "The package containing the PSR-7 interfaces" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2020-02-05T20:36:27+00:00" + }, { "name": "guzzlehttp/psr7", "version": "1.5.2", @@ -1610,6 +1662,52 @@ ], "time": "2019-10-21T21:32:25+00:00" }, + { + "name": "nikic/fast-route", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/FastRoute.git", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|~5.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "FastRoute\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + } + ], + "description": "Fast request router for PHP", + "keywords": [ + "router", + "routing" + ], + "time": "2018-02-13T20:26:39+00:00" + }, { "name": "opis/closure", "version": "3.1.1", @@ -1813,6 +1911,58 @@ ], "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "time": "2019-04-30T12:38:16+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -1864,23 +2014,137 @@ "time": "2016-08-06T14:39:51+00:00" }, { - "name": "psr/log", - "version": "1.0.0", + "name": "psr/http-server-handler", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", "shasum": "" }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "time": "2018-10-30T16:46:14+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "time": "2018-10-30T17:12:04+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1894,12 +2158,13 @@ } ], "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], - "time": "2012-12-21T11:40:51+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { "name": "psr/simple-cache", @@ -2449,29 +2714,41 @@ "time": "2019-06-21T08:51:04+00:00" }, { - "name": "slim/slim", - "version": "2.6.2", + "name": "slim/psr7", + "version": "0.4.0", "source": { "type": "git", - "url": "https://github.com/slimphp/Slim.git", - "reference": "20a02782f76830b67ae56a5c08eb1f563c351a37" + "url": "https://github.com/slimphp/Slim-Psr7.git", + "reference": "d312896b7cd4aca7d4b86b64acdfcb5cc3da758f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37", - "reference": "20a02782f76830b67ae56a5c08eb1f563c351a37", + "url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/d312896b7cd4aca7d4b86b64acdfcb5cc3da758f", + "reference": "d312896b7cd4aca7d4b86b64acdfcb5cc3da758f", "shasum": "" }, "require": { - "php": ">=5.3.0" + "fig/http-message-util": "^1.1", + "php": "^7.1", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^2" }, - "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption" + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-json": "*", + "http-interop/http-factory-tests": "^0.5.0", + "php-http/psr7-integration-tests": "dev-master", + "phpstan/phpstan": "^0.10", + "phpunit/phpunit": "^6.0|^7.0", + "squizlabs/php_codesniffer": "^3.3" }, "type": "library", "autoload": { - "psr-0": { - "Slim": "." + "psr-4": { + "Slim\\Psr7\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2481,18 +2758,136 @@ "authors": [ { "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" + "email": "hello@joshlockhart.com", + "homepage": "http://joshlockhart.com" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://silentworks.co.uk" + }, + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" } ], - "description": "Slim Framework, a PHP micro framework", - "homepage": "http://github.com/codeguy/Slim", + "description": "Strict PSR-7 implementation", + "homepage": "https://www.slimframework.com", "keywords": [ - "microframework", - "rest", + "http", + "psr-7", + "psr7" + ], + "time": "2019-08-02T17:06:08+00:00" + }, + { + "name": "slim/slim", + "version": "4.5.0", + "source": { + "type": "git", + "url": "https://github.com/slimphp/Slim.git", + "reference": "5613cbb521081ed676d5d7eb3e44f2b80a818c24" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/5613cbb521081ed676d5d7eb3e44f2b80a818c24", + "reference": "5613cbb521081ed676d5d7eb3e44f2b80a818c24", + "shasum": "" + }, + "require": { + "ext-json": "*", + "nikic/fast-route": "^1.3", + "php": "^7.2", + "psr/container": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0", + "psr/http-server-middleware": "^1.0", + "psr/log": "^1.1" + }, + "require-dev": { + "adriansuter/php-autoload-override": "^1.0", + "ext-simplexml": "*", + "guzzlehttp/psr7": "^1.5", + "http-interop/http-factory-guzzle": "^1.0", + "laminas/laminas-diactoros": "^2.1", + "nyholm/psr7": "^1.1", + "nyholm/psr7-server": "^0.3.0", + "phpspec/prophecy": "^1.10", + "phpstan/phpstan": "^0.11.5", + "phpunit/phpunit": "^8.5", + "slim/http": "^1.0", + "slim/psr7": "^1.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "ext-simplexml": "Needed to support XML format in BodyParsingMiddleware", + "ext-xml": "Needed to support XML format in BodyParsingMiddleware", + "php-di/php-di": "PHP-DI is the recommended container library to be used with Slim", + "slim/psr7": "Slim PSR-7 implementation. See https://www.slimframework.com/docs/v4/start/installation.html for more information." + }, + "type": "library", + "autoload": { + "psr-4": { + "Slim\\": "Slim" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Josh Lockhart", + "email": "hello@joshlockhart.com", + "homepage": "https://joshlockhart.com" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://silentworks.co.uk" + }, + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" + }, + { + "name": "Gabriel Manricks", + "email": "gmanricks@me.com", + "homepage": "http://gabrielmanricks.com" + } + ], + "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", + "homepage": "https://www.slimframework.com", + "keywords": [ + "api", + "framework", + "micro", "router" ], - "time": "2015-03-08T18:41:17+00:00" + "funding": [ + { + "url": "https://opencollective.com/slimphp", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slim/slim", + "type": "tidelift" + } + ], + "time": "2020-04-14T20:49:48+00:00" }, { "name": "spatie/async", diff --git a/install/core/Installer.php b/install/core/Installer.php index fddb8caea0..57e9bd14f8 100644 --- a/install/core/Installer.php +++ b/install/core/Installer.php @@ -163,8 +163,7 @@ class Installer protected function auth() { if (!$this->isAuth) { - $auth = new \Espo\Core\Utils\Auth($this->app->getContainer()); - $auth->useNoAuth(); + $this->app->setupSystemUser(); $this->isAuth = true; }