Skip to content

EspoCRM – Open Source CRM Application

Param adminExtensionManage

Yurii38d56a0f1036
diff --git a/application/Espo/Controllers/Extension.php b/application/Espo/Controllers/Extension.php
index 547b4e6985..252fb1adb0 100644
--- a/application/Espo/Controllers/Extension.php
+++ b/application/Espo/Controllers/Extension.php
@@ -53,7 +53,7 @@ class Extension extends RecordBase
*/
public function postActionUpload(Request $request): stdClass
{
- $this->assertUpgradeAllowed();
+ $this->assertUploadAllowed();
$body = $request->getBodyContents();
@@ -81,11 +81,9 @@ class Extension extends RecordBase
*/
public function postActionInstall(Request $request): bool
{
- $data = $request->getParsedBody();
+ $this->assertInstallAllowed();
- if ($this->config->get('restrictedMode')) {
- throw new Forbidden();
- }
+ $data = $request->getParsedBody();
$manager = $this->createManager();
@@ -100,11 +98,9 @@ class Extension extends RecordBase
*/
public function postActionUninstall(Request $request): bool
{
- $data = $request->getParsedBody();
+ $this->assertInstallAllowed();
- if ($this->config->get('restrictedMode')) {
- throw new Forbidden();
- }
+ $data = $request->getParsedBody();
$manager = $this->createManager();
@@ -121,7 +117,7 @@ class Extension extends RecordBase
{
$params = $request->getRouteParams();
- $this->assertUpgradeAllowed();
+ $this->assertUploadAllowed();
$manager = $this->createManager();
@@ -148,7 +144,21 @@ class Extension extends RecordBase
/**
* @throws Forbidden
*/
- private function assertUpgradeAllowed(): void
+ private function assertInstallAllowed(): void
+ {
+ if ($this->config->get('restrictedMode')) {
+ throw new Forbidden("Not allowed in restricted mode.");
+ }
+
+ if ($this->config->get('adminExtensionManage') !== true) {
+ throw new Forbidden("Cannot manage extensions as `adminExtensionManage` is not enabled.");
+ }
+ }
+
+ /**
+ * @throws Forbidden
+ */
+ private function assertUploadAllowed(): void
{
if ($this->config->get('restrictedMode')) {
throw new Forbidden("Not allowed in restricted mode.");
@@ -158,6 +168,10 @@ class Extension extends RecordBase
throw new Forbidden("Cannot upload extensions as `adminExtensionUpload` is not enabled.");
}
+ if ($this->config->get('adminExtensionManage') !== true) {
+ throw new Forbidden("Cannot manage extensions as `adminExtensionManage` is not enabled.");
+ }
+
if ($this->config->get('adminUpgradeDisabled')) {
throw new Forbidden("Disabled with `adminUpgradeDisabled` parameter.");
}
diff --git a/application/Espo/Resources/defaults/config.php b/application/Espo/Resources/defaults/config.php
index fc5f47df81..98a7244656 100644
--- a/application/Espo/Resources/defaults/config.php
+++ b/application/Espo/Resources/defaults/config.php
@@ -310,6 +310,7 @@ return [
'phoneNumberPreferredCountryList' => ['us', 'de'],
'adminUpgradeDisabled' => false,
'adminUpgrade' => false,
+ 'adminExtensionManage' => true,
'adminExtensionUpload' => true,
'wysiwygCodeEditorDisabled' => false,
'customPrefixDisabled' => false,
diff --git a/application/Espo/Resources/defaults/systemConfig.php b/application/Espo/Resources/defaults/systemConfig.php
index 92eda39adc..0a05900aae 100644
--- a/application/Espo/Resources/defaults/systemConfig.php
+++ b/application/Espo/Resources/defaults/systemConfig.php
@@ -64,6 +64,7 @@ return [
'instanceId',
'adminUpgradeDisabled',
'adminUpgrade',
+ 'adminExtensionManage',
'adminExtensionUpload',
'userLimit',
'portalUserLimit',