Skip to content

Commit cccb609

Browse files
Merge remote-tracking branch 'origin/2.4-develop' into CABPI-410
2 parents 51fc626 + 32b3b58 commit cccb609

File tree

134 files changed

+2909
-848
lines changed

Some content is hidden

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

134 files changed

+2909
-848
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Bug report
2+
description: Technical issue with the Magento 2 core components
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
Please read [our guidelines](https://developer.adobe.com/commerce/contributor/guides/code-contributions/#report-an-issue) before submitting the issue.
8+
- type: textarea
9+
attributes:
10+
label: Preconditions and environment
11+
description: |
12+
Describe your environment.
13+
Provide all the details that will help us to reproduce the bug.
14+
value: |
15+
- Magento version
16+
- Anything else that would help a developer reproduce the bug
17+
- type: textarea
18+
attributes:
19+
label: Steps to reproduce
20+
description: |
21+
Provide a set of clear steps to reproduce this bug.
22+
placeholder: |
23+
Example:
24+
1. Navigate to storefront as a guest.
25+
2. Open Test Category.
26+
3. Click “Add to Cart” on the Virtual Product.
27+
4. Open mini shopping cart and click “Proceed to Checkout”.
28+
validations:
29+
required: true
30+
- type: textarea
31+
attributes:
32+
label: Expected result
33+
description: |
34+
Tell us what you expected to happen.
35+
placeholder: |
36+
Example:
37+
Order is placed successfully, customer is redirected to the success page.
38+
validations:
39+
required: true
40+
- type: textarea
41+
attributes:
42+
label: Actual result
43+
description: |
44+
Tell us what happened. Include error messages and issues.
45+
placeholder: |
46+
Example:
47+
“Place order” button is not visible, order cannot be placed.
48+
validations:
49+
required: true
50+
- type: textarea
51+
attributes:
52+
label: Additional information
53+
description: |
54+
Additional information is often requested when the bug report is processed. You can save time by providing both Magento and browser logs, screenshots, repository branch and HEAD commit you checked out to install Magento and any other artifacts related to the issue.
55+
Also, links to the comments with important information, Root Cause analysis, additional video recordings; and anything else that is important for the issue and at some reason cannot be added to other sections.
56+
- type: textarea
57+
attributes:
58+
label: Release note
59+
description: |
60+
Help us to provide meaningful release notes to the community.
61+
- type: checkboxes
62+
attributes:
63+
label: Triage and priority
64+
description: |
65+
Provide [Severity](https://developer.adobe.com/commerce/contributor/guides/code-contributions/#community-backlog-priority) assessment for the Issue as a Reporter.
66+
This information helps us during the Confirmation and Issue triage processes.
67+
options:
68+
- label: 'Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._'
69+
- label: 'Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._'
70+
- label: 'Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._'
71+
- label: 'Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._'
72+
- label: 'Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._'

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Magento values the contributions of the security research community, and we look
44

55
## Where should I report security issues?
66

7-
We strongly encourage you to report all security issues privately via our [bug bounty program](https://hackerone.com/magento). Please provide us with relevant technical details and repro steps to expedite our investigation. If you prefer not to use HackerOne, email us directly at `psirt@adobe.com` with details and repro steps.
7+
We strongly encourage you to report all security issues privately via our [bug bounty program](https://hackerone.com/adobe). Please provide us with relevant technical details and repro steps to expedite our investigation. If you prefer not to use HackerOne, email us directly at `psirt@adobe.com` with details and repro steps.
88

99
## Learning More About Security
1010
To learn more about securing a Magento store, please visit the [Security Center](https://magento.com/security).

app/code/Magento/AdminAdobeIms/Controller/Adminhtml/OAuth/ImsCallback.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ public function execute(): Redirect
102102
$tokenResponse = $this->adminImsConnection->getTokenResponse($code);
103103
$accessToken = $tokenResponse->getAccessToken();
104104

105-
//check organization assignment
106-
$this->adminOrganizationService->checkOrganizationAllocation($accessToken);
107-
108105
//get profile info to check email
109106
$profile = $this->adminImsConnection->getProfile($accessToken);
110107
if (empty($profile['email'])) {
111108
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
112109
}
110+
111+
//check membership in organization
112+
$this->adminOrganizationService->checkOrganizationMembership($accessToken);
113+
113114
$this->adminLoginProcessService->execute($tokenResponse, $profile);
114115
} catch (AdobeImsAuthorizationException $e) {
115116
$this->logger->error($e->getMessage());

app/code/Magento/AdminAdobeIms/Controller/Adminhtml/OAuth/ImsReauthCallback.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ public function execute(): ResultInterface
118118
}
119119

120120
$tokenResponse = $this->adminImsConnection->getTokenResponse($code);
121+
$accessToken = $tokenResponse->getAccessToken();
121122

122-
$profile = $this->adminImsConnection->getProfile($tokenResponse->getAccessToken());
123+
$profile = $this->adminImsConnection->getProfile($accessToken);
123124
if (empty($profile['email'])) {
124125
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
125126
}
126127

127-
$accessToken = $tokenResponse->getAccessToken();
128-
$this->adminOrganizationService->checkOrganizationAllocation($accessToken);
128+
//check membership in organization
129+
$this->adminOrganizationService->checkOrganizationMembership($accessToken);
130+
129131
$this->adminReauthProcessService->execute($tokenResponse);
130132

131133
$response = sprintf(
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Plugin\Block\Adminhtml\Integration\Edit\Tab;
10+
11+
use Magento\AdminAdobeIms\Plugin\AdobeImsReauth\AddAdobeImsReAuthButton;
12+
use Magento\AdminAdobeIms\Service\ImsConfig;
13+
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
14+
15+
class AddReAuthVerification
16+
{
17+
/**
18+
* @var AddAdobeImsReAuthButton
19+
*/
20+
private AddAdobeImsReAuthButton $adobeImsReAuthButton;
21+
22+
/**
23+
* @var ImsConfig
24+
*/
25+
private ImsConfig $adminAdobeImsConfig;
26+
27+
/**
28+
* @param AddAdobeImsReAuthButton $adobeImsReAuthButton
29+
* @param ImsConfig $adminAdobeImsConfig
30+
*/
31+
public function __construct(
32+
AddAdobeImsReAuthButton $adobeImsReAuthButton,
33+
ImsConfig $adminAdobeImsConfig
34+
) {
35+
$this->adobeImsReAuthButton = $adobeImsReAuthButton;
36+
$this->adminAdobeImsConfig = $adminAdobeImsConfig;
37+
}
38+
39+
/**
40+
* Add adobeIms reAuth button to integration new/edit form
41+
*
42+
* @param Info $subject
43+
* @return void
44+
*/
45+
public function beforeGetFormHtml(Info $subject): void
46+
{
47+
if ($this->adminAdobeImsConfig->enabled()) {
48+
$form = $subject->getForm();
49+
if (is_object($form)) {
50+
$verificationFieldset = $form->getElement('current_user_verification_fieldset');
51+
if ($verificationFieldset !== null) {
52+
$this->adobeImsReAuthButton->addAdobeImsReAuthButton($verificationFieldset);
53+
$subject->setForm($form);
54+
}
55+
}
56+
}
57+
}
58+
}

app/code/Magento/AdminAdobeIms/Plugin/ResetAttemptForBackendObserverPlugin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ public function __construct(ImsConfig $adminImsConfig)
3333
* @param ResetAttemptForBackendObserver $subject
3434
* @param callable $proceed
3535
* @param Observer $observer
36+
* @return void
3637
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3738
*/
38-
public function aroundExecute(ResetAttemptForBackendObserver $subject, callable $proceed, Observer $observer)
39+
public function aroundExecute(ResetAttemptForBackendObserver $subject, callable $proceed, Observer $observer): void
3940
{
4041
if (!$this->adminImsConfig->enabled()) {
41-
return $proceed($observer);
42+
$proceed($observer);
4243
}
4344
}
4445
}

app/code/Magento/AdminAdobeIms/Service/ImsConfig.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ImsConfig extends Config
3434
public const XML_PATH_ADMIN_AUTH_URL_PATTERN = 'adobe_ims/integration/admin/auth_url_pattern';
3535
public const XML_PATH_ADMIN_REAUTH_URL_PATTERN = 'adobe_ims/integration/admin/reauth_url_pattern';
3636
public const XML_PATH_ADMIN_ADOBE_IMS_SCOPES = 'adobe_ims/integration/admin/scopes';
37+
public const XML_PATH_ORGANIZATION_MEMBERSHIP_URL = 'adobe_ims/integration/organization_membership_url';
3738

3839
private const OAUTH_CALLBACK_URL = 'adobe_ims_auth/oauth/';
3940

@@ -376,4 +377,19 @@ public function getCertificateUrl(string $fileName): string
376377
{
377378
return $this->scopeConfig->getValue(self::XML_PATH_CERTIFICATE_PATH) . $fileName;
378379
}
380+
381+
/**
382+
* Get url to check organization membership
383+
*
384+
* @param string $orgId
385+
* @return string
386+
*/
387+
public function getOrganizationMembershipUrl(string $orgId): string
388+
{
389+
return str_replace(
390+
['#{org_id}'],
391+
[$orgId],
392+
$this->scopeConfig->getValue(self::XML_PATH_ORGANIZATION_MEMBERSHIP_URL)
393+
);
394+
}
379395
}

app/code/Magento/AdminAdobeIms/Service/ImsOrganizationService.php

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\AdminAdobeIms\Service;
1010

1111
use Magento\AdminAdobeIms\Exception\AdobeImsOrganizationAuthorizationException;
12+
use Magento\Framework\HTTP\Client\CurlFactory;
1213

1314
class ImsOrganizationService
1415
{
@@ -17,33 +18,68 @@ class ImsOrganizationService
1718
*/
1819
private ImsConfig $adminImsConfig;
1920

21+
/**
22+
* @var CurlFactory
23+
*/
24+
private CurlFactory $curlFactory;
25+
2026
/**
2127
* @param ImsConfig $adminImsConfig
28+
* @param CurlFactory $curlFactory
2229
*/
2330
public function __construct(
24-
ImsConfig $adminImsConfig
31+
ImsConfig $adminImsConfig,
32+
CurlFactory $curlFactory
2533
) {
2634
$this->adminImsConfig = $adminImsConfig;
35+
$this->curlFactory = $curlFactory;
2736
}
2837

2938
/**
30-
* Check if user is assigned to organization
39+
* Check if user is a member of Adobe Organization
3140
*
32-
* @param string $token
33-
* @return bool
41+
* @param string $access_token
42+
* @return void
3443
* @throws AdobeImsOrganizationAuthorizationException
3544
*/
36-
public function checkOrganizationAllocation(string $token): bool
45+
public function checkOrganizationMembership(string $access_token): void
3746
{
38-
$configuredOrganization = $this->adminImsConfig->getOrganizationId();
47+
$configuredOrganizationId = $this->adminImsConfig->getOrganizationId();
3948

40-
//@TODO CABPI-324: Change Org check to use new endpoint
41-
if ($configuredOrganization === '' || !$token) {
49+
if ($configuredOrganizationId === '' || !$access_token) {
4250
throw new AdobeImsOrganizationAuthorizationException(
43-
__('User is not assigned to defined organization.')
51+
__('Can\'t check user membership in organization.')
4452
);
4553
}
4654

47-
return true;
55+
try {
56+
$curl = $this->curlFactory->create();
57+
58+
$curl->addHeader('Content-Type', 'application/x-www-form-urlencoded');
59+
$curl->addHeader('cache-control', 'no-cache');
60+
$curl->addHeader('Authorization', 'Bearer ' . $access_token);
61+
62+
$orgCheckUrl = $this->adminImsConfig->getOrganizationMembershipUrl($configuredOrganizationId);
63+
$curl->get($orgCheckUrl);
64+
65+
if ($curl->getBody() === '') {
66+
throw new AdobeImsOrganizationAuthorizationException(
67+
__('Could not check Organization Membership. Response is empty.')
68+
);
69+
}
70+
71+
$response = $curl->getBody();
72+
73+
if ($response !== 'true') {
74+
throw new AdobeImsOrganizationAuthorizationException(
75+
__('User is not a member of configured Adobe Organization.')
76+
);
77+
}
78+
79+
} catch (\Exception $exception) {
80+
throw new AdobeImsOrganizationAuthorizationException(
81+
__('Organization Membership check can\'t be performed')
82+
);
83+
}
4884
}
4985
}

app/code/Magento/AdminAdobeIms/Test/Mftf/Test/AdminAdobeImsEnabledInfoCommandTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<description value="Runs bin/magento admin:adobe-ims info command"/>
1717
<severity value="MINOR"/>
1818
<group value="admin_ims"/>
19+
<skip>
20+
<issueId value="AC-3153">Skipped</issueId>
21+
</skip>
1922
<testCaseId value="CABPI-186"/>
2023
</annotations>
2124
<before>

0 commit comments

Comments
 (0)