acl fixes
This commit is contained in:
@@ -32,7 +32,6 @@ namespace Espo\Core\Select\AccessControl;
|
||||
use Espo\Core\Select\OrmSelectBuilder;
|
||||
|
||||
use Espo\Core\{
|
||||
Exceptions\Error,
|
||||
Select\SelectManager,
|
||||
Select\AccessControl\FilterFactory as AccessControlFilterFactory,
|
||||
Select\AccessControl\FilterResolverFactory as AccessControlFilterResolverFactory,
|
||||
@@ -43,6 +42,8 @@ use Espo\{
|
||||
Entities\User,
|
||||
};
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class Applier
|
||||
{
|
||||
private string $entityType;
|
||||
@@ -111,7 +112,7 @@ class Applier
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error("No access filter '{$filterName}' for '{$this->entityType}'.");
|
||||
throw new RuntimeException("No access filter '{$filterName}' for '{$this->entityType}'.");
|
||||
}
|
||||
|
||||
private function applyMandatoryFilter(QueryBuilder $queryBuilder): void
|
||||
|
||||
@@ -29,10 +29,8 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl;
|
||||
|
||||
class BypassFilterResolver implements FilterResolver
|
||||
{
|
||||
public function resolve(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @deprecated Use `\Espo\Core\Select\AccessControl\FilterResolvers\Bypass` instead.
|
||||
* @todo Remove in v8.0.
|
||||
*/
|
||||
class BypassFilterResolver extends \Espo\Core\Select\AccessControl\FilterResolvers\Bypass {}
|
||||
|
||||
@@ -45,6 +45,8 @@ use Espo\{
|
||||
Entities\User,
|
||||
};
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class FilterFactory
|
||||
{
|
||||
private $injectableFactory;
|
||||
@@ -60,15 +62,12 @@ class FilterFactory
|
||||
$this->aclManager = $aclManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Error
|
||||
*/
|
||||
public function create(string $entityType, User $user, string $name): Filter
|
||||
{
|
||||
$className = $this->getClassName($entityType, $name);
|
||||
|
||||
if (!$className) {
|
||||
throw new Error("Access control filter '{$name}' for '{$entityType}' does not exist.");
|
||||
throw new RuntimeException("Access control filter '{$name}' for '{$entityType}' does not exist.");
|
||||
}
|
||||
|
||||
$bindingData = new BindingData();
|
||||
@@ -92,9 +91,6 @@ class FilterFactory
|
||||
return $this->injectableFactory->createWithBinding($className, $bindingContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Error
|
||||
*/
|
||||
public function has(string $entityType, string $name): bool
|
||||
{
|
||||
return (bool) $this->getClassName($entityType, $name);
|
||||
@@ -102,12 +98,11 @@ class FilterFactory
|
||||
|
||||
/**
|
||||
* @return class-string<Filter>
|
||||
* @throws Error
|
||||
*/
|
||||
private function getClassName(string $entityType, string $name): ?string
|
||||
{
|
||||
if (!$name) {
|
||||
throw new Error("Empty access control filter name.");
|
||||
throw new RuntimeException("Empty access control filter name.");
|
||||
}
|
||||
|
||||
/** @var ?class-string<Filter> */
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\FilterResolvers;
|
||||
|
||||
use Espo\Core\Select\AccessControl\FilterResolver;
|
||||
|
||||
class Bypass implements FilterResolver
|
||||
{
|
||||
public function resolve(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,5 @@ class All implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
"accessControlFilterClassNameMap": {
|
||||
"mandatory": "Espo\\Classes\\Select\\Import\\AccessControlFilters\\Mandatory"
|
||||
},
|
||||
"accessControlFilterResolverClassName": "Espo\\Core\\Select\\AccessControl\\BypassFilterResolver"
|
||||
"accessControlFilterResolverClassName": "Espo\\Core\\Select\\AccessControl\\FilterResolvers\\Bypass"
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
"accessControlFilterClassNameMap": {
|
||||
"mandatory": "Espo\\Classes\\Select\\Webhook\\AccessControlFilters\\Mandatory"
|
||||
},
|
||||
"accessControlFilterResolverClassName": "Espo\\Core\\Select\\AccessControl\\BypassFilterResolver"
|
||||
"accessControlFilterResolverClassName": "Espo\\Core\\Select\\AccessControl\\FilterResolvers\\Bypass"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user