Skip to content

Commit 27d696d

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into ACP2E-926
2 parents 3b324c9 + e0d650c commit 27d696d

File tree

1,033 files changed

+25407
-132030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,033 files changed

+25407
-132030
lines changed

app/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
</div>
2828
HTML;
2929
}
30+
http_response_code(503);
3031
exit(1);
3132
}
3233

app/code/Magento/AdminAdobeIms/Api/Data/ImsWebapiInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Api\Data;

app/code/Magento/AdminAdobeIms/Api/Data/ImsWebapiSearchResultsInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Api\Data;

app/code/Magento/AdminAdobeIms/Api/ImsLogOutInterface.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/code/Magento/AdminAdobeIms/Api/ImsWebapiRepositoryInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Api;

app/code/Magento/AdminAdobeIms/App/Action/Plugin/Authentication.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\App\Action\Plugin;

app/code/Magento/AdminAdobeIms/Block/Adminhtml/System/Config/Form/Field/Disabled.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Block\Adminhtml\System\Config\Form\Field;

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsDisableCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Console\Command;

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsEnableCommand.php

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Console\Command;
109

11-
use Magento\AdminAdobeIms\Model\ImsConnection;
12-
use Magento\AdminAdobeIms\Service\UpdateTokensService;
1310
use Magento\AdminAdobeIms\Service\ImsCommandOptionService;
1411
use Magento\AdminAdobeIms\Service\ImsConfig;
12+
use Magento\AdminAdobeIms\Service\UpdateTokensService;
13+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
14+
use Magento\Authorization\Model\Acl\Role\Group;
15+
use Magento\Authorization\Model\ResourceModel\Role\CollectionFactory;
16+
use Magento\Authorization\Model\Role;
17+
use Magento\Authorization\Model\UserContextInterface;
1518
use Magento\Framework\App\Cache\Type\Config;
1619
use Magento\Framework\App\Cache\TypeListInterface;
20+
use Magento\Framework\App\ObjectManager;
1721
use Magento\Framework\Console\Cli;
1822
use Magento\Framework\Exception\InvalidArgumentException;
1923
use Magento\Framework\Exception\LocalizedException;
@@ -53,11 +57,6 @@ class AdminAdobeImsEnableCommand extends Command
5357
*/
5458
private ImsConfig $adminImsConfig;
5559

56-
/**
57-
* @var ImsConnection
58-
*/
59-
private ImsConnection $adminImsConnection;
60-
6160
/**
6261
* @var ImsCommandOptionService
6362
*/
@@ -73,26 +72,47 @@ class AdminAdobeImsEnableCommand extends Command
7372
*/
7473
private UpdateTokensService $updateTokensService;
7574

75+
/**
76+
* @var Role
77+
*/
78+
private Role $role;
79+
80+
/**
81+
* @var CollectionFactory
82+
*/
83+
private CollectionFactory $roleCollection;
84+
85+
/**
86+
* @var AuthorizationInterface
87+
*/
88+
private AuthorizationInterface $authorization;
89+
7690
/**
7791
* @param ImsConfig $adminImsConfig
78-
* @param ImsConnection $adminImsConnection
7992
* @param ImsCommandOptionService $imsCommandOptionService
8093
* @param TypeListInterface $cacheTypeList
8194
* @param UpdateTokensService $updateTokensService
95+
* @param AuthorizationInterface $authorization
96+
* @param Role|null $role
97+
* @param CollectionFactory|null $roleCollection
8298
*/
8399
public function __construct(
84100
ImsConfig $adminImsConfig,
85-
ImsConnection $adminImsConnection,
86101
ImsCommandOptionService $imsCommandOptionService,
87102
TypeListInterface $cacheTypeList,
88-
UpdateTokensService $updateTokensService
103+
UpdateTokensService $updateTokensService,
104+
AuthorizationInterface $authorization,
105+
Role $role = null,
106+
CollectionFactory $roleCollection = null
89107
) {
90108
parent::__construct();
91109
$this->adminImsConfig = $adminImsConfig;
92-
$this->adminImsConnection = $adminImsConnection;
93110
$this->imsCommandOptionService = $imsCommandOptionService;
94111
$this->cacheTypeList = $cacheTypeList;
95112
$this->updateTokensService = $updateTokensService;
113+
$this->authorization = $authorization;
114+
$this->role = $role ?: ObjectManager::getInstance()->get(Role::class);
115+
$this->roleCollection = $roleCollection ?: ObjectManager::getInstance()->get(CollectionFactory::class);
96116

97117
$this->setName('admin:adobe-ims:enable')
98118
->setDescription('Enable Adobe IMS Module.')
@@ -164,6 +184,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
164184
if ($clientId && $clientSecret && $organizationId && $isTwoFactorAuthEnabled) {
165185
$enabled = $this->enableModule($clientId, $clientSecret, $organizationId, $isTwoFactorAuthEnabled);
166186
if ($enabled) {
187+
$this->saveImsAuthorizationRole();
167188
$output->writeln(__('Admin Adobe IMS integration is enabled'));
168189
return Cli::RETURN_SUCCESS;
169190
}
@@ -182,6 +203,27 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
182203
}
183204
}
184205

206+
/**
207+
* Save new Adobe IMS role
208+
*
209+
* @return bool
210+
* @throws \Exception
211+
*/
212+
private function saveImsAuthorizationRole(): bool
213+
{
214+
$roleCollection = $this->roleCollection->create()->addFieldToFilter('role_name', 'Adobe Ims');
215+
if (!$roleCollection->getSize()) {
216+
$this->role->setRoleName('Adobe Ims')
217+
->setUserType((string)UserContextInterface::USER_TYPE_ADMIN)
218+
->setUserId(0)
219+
->setRoleType(Group::ROLE_TYPE)
220+
->setParentId(0)
221+
->save();
222+
}
223+
224+
return true;
225+
}
226+
185227
/**
186228
* Enable Admin Adobe IMS Module when testConnection was successfully
187229
*
@@ -199,7 +241,7 @@ private function enableModule(
199241
string $organizationId,
200242
bool $isTwoFactorAuthEnabled
201243
): bool {
202-
$testAuth = $this->adminImsConnection->testAuth($clientId);
244+
$testAuth = $this->authorization->testAuth($clientId);
203245
if ($testAuth) {
204246
$this->adminImsConfig->enableModule($clientId, $clientSecret, $organizationId, $isTwoFactorAuthEnabled);
205247
$this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER);

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsInfoCommand.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\AdminAdobeIms\Console\Command;
109

11-
use Magento\AdminAdobeIms\Model\ImsConnection;
1210
use Magento\AdminAdobeIms\Service\ImsConfig;
11+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1312
use Magento\Framework\Console\Cli;
1413
use Symfony\Component\Console\Command\Command;
1514
use Symfony\Component\Console\Input\InputInterface;
@@ -41,21 +40,21 @@ class AdminAdobeImsInfoCommand extends Command
4140
private ImsConfig $adminImsConfig;
4241

4342
/**
44-
* @var ImsConnection
43+
* @var AuthorizationInterface
4544
*/
46-
private ImsConnection $adminImsConnection;
45+
private AuthorizationInterface $authorization;
4746

4847
/**
4948
* @param ImsConfig $adminImsConfig
50-
* @param ImsConnection $adminImsConnection
49+
* @param AuthorizationInterface $authorization
5150
*/
5251
public function __construct(
5352
ImsConfig $adminImsConfig,
54-
ImsConnection $adminImsConnection
53+
AuthorizationInterface $authorization
5554
) {
5655
parent::__construct();
5756
$this->adminImsConfig = $adminImsConfig;
58-
$this->adminImsConnection = $adminImsConnection;
57+
$this->authorization = $authorization;
5958

6059
$this->setName('admin:adobe-ims:info')
6160
->setDescription('Information of Adobe IMS Module configuration');
@@ -69,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
6968
try {
7069
if ($this->adminImsConfig->enabled()) {
7170
$clientId = $this->adminImsConfig->getApiKey();
72-
if ($this->adminImsConnection->testAuth($clientId)) {
71+
if ($this->authorization->testAuth($clientId)) {
7372
$clientSecret = $this->adminImsConfig->getPrivateKey() ? 'configured' : 'not configured';
7473
$output->writeln(self::CLIENT_ID_NAME . ': ' . $clientId);
7574
$output->writeln(self::ORGANIZATION_ID_NAME . ': ' . $this->adminImsConfig->getOrganizationId());

0 commit comments

Comments
 (0)