Skip to content

Commit 3c2dd44

Browse files
authored
Merge branch '2.4-develop' into patch-3
2 parents e2f29b5 + 6dbb7fc commit 3c2dd44

File tree

597 files changed

+12753
-3306
lines changed

Some content is hidden

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

597 files changed

+12753
-3306
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,80 @@
1-
# Contributor Covenant Code of Conduct
1+
# Magento Code of Conduct
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
5+
We as members, contributors, and leaders pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
69

710
## Our Standards
811

9-
Examples of behavior that contributes to creating a positive environment include:
12+
Examples of behavior that contribute to a positive environment for our project and community include:
13+
14+
15+
* Demonstrating empathy and kindness toward other people
16+
* Being respectful of differing opinions, viewpoints, and experiences
17+
* Giving and gracefully accepting constructive feedback
18+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
19+
* Focusing on what is best, not just for us as individuals but for the overall community
1020

11-
* Using welcoming and inclusive language
12-
* Being respectful of differing viewpoints and experiences
13-
* Gracefully accepting constructive criticism
14-
* Focusing on what is best for the community
15-
* Showing empathy towards other community members
1621

1722
Examples of unacceptable behavior by participants include:
1823

19-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20-
* Trolling, insulting/derogatory comments, and personal or political attacks
24+
* The use of sexualized language or imagery and sexual attention or advances of any kind
25+
* Trolling, insulting or derogatory comments, and personal or political attacks
2126
* Public or private harassment
22-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
27+
* Publishing others private information, such as a physical or email address, without their explicit permission
2328
* Other conduct which could reasonably be considered inappropriate in a professional setting
2429

30+
2531
## Our Responsibilities
2632

27-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
33+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any instances of unacceptable behavior.
2834

29-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
35+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
3036

3137
## Scope
3238

33-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
39+
This Code of Conduct applies when an individual is representing the project or its community both within project spaces and in public spaces. Examples of representing a project or community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
3440

3541
## Enforcement
3642

37-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at engcom@magento.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
43+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by first contacting the project team at engcom@adobe.com. Oversight of Adobe projects is handled by the Adobe Open Source Office, which has final say in any violations and enforcement of this Code of Conduct and can be reached at [email protected]. All complaints will be reviewed and investigated promptly and fairly.
3844

39-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
45+
The project team must respect the privacy and security of the reporter of any incident.
4046

41-
## Attribution
47+
Project maintainers who do not follow or enforce the Code of Conduct may face temporary or permanent repercussions as determined by other members of the project's leadership or the Adobe Open Source Office.
48+
49+
50+
## Enforcement Guidelines
51+
52+
Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem to be in violation of this Code of Conduct:
53+
54+
### 1. Correction
55+
56+
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
57+
Consequence: A private, written warning from project maintainers describing the violation and why the behavior was unacceptable. A public apology may be requested from the violator before any further involvement in the project by violator.
4258

43-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
59+
### 2. Warning
60+
61+
Community Impact: A relatively minor violation through a single incident or series of actions.
62+
63+
Consequence: A written warning from project maintainers that includes stated consequences for continued unacceptable behavior. Violator must refrain from interacting with the people involved for a specified period of time as determined by the project maintainers, including, but not limited to, unsolicited interaction with those enforcing the Code of Conduct through channels such as community spaces and social media. Continued violations may lead to a temporary or permanent ban.
64+
65+
### 3. Temporary Ban
66+
67+
Community Impact: A more serious violation of community standards, including sustained unacceptable behavior.
68+
69+
Consequence: A temporary ban from any interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Failure to comply with the temporary ban may lead to a permanent ban.
70+
71+
### 4. Permanent Ban
72+
73+
Community Impact: Demonstrating a consistent pattern of violation of community standards or an egregious violation of community standards, including, but not limited to, sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
74+
75+
Consequence: A permanent ban from any interaction with the community.
76+
77+
78+
## Attribution
4479

45-
[homepage]: http://contributor-covenant.org
46-
[version]: http://contributor-covenant.org/version/1/4/
80+
This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

app/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#ini_set('display_errors', 1);
1515

1616
/* PHP version validation */
17-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 70400) {
17+
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80100) {
1818
if (PHP_SAPI == 'cli') {
19-
echo 'Magento supports PHP 7.4.0 or later. ' .
19+
echo 'Magento supports PHP 8.1.0 or later. ' .
2020
'Please read https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html';
2121
} else {
2222
echo <<<HTML
2323
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
24-
<p>Magento supports PHP 7.4.0 or later. Please read
24+
<p>Magento supports PHP 8.1.0 or later. Please read
2525
<a target="_blank" href="https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html">
2626
Magento System Requirements</a>.
2727
</div>

app/code/Magento/AdminAdobeIms/Model/Authorization/AdobeImsAdminTokenUserService.php

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
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\Model\Authorization;
109

10+
use Magento\AdminAdobeIms\Api\SaveImsUserInterface;
1111
use Magento\AdminAdobeIms\Exception\AdobeImsAuthorizationException;
1212
use Magento\AdminAdobeIms\Service\AdminLoginProcessService;
1313
use Magento\AdminAdobeIms\Service\AdminReauthProcessService;
1414
use Magento\AdminAdobeIms\Service\ImsConfig;
1515
use Magento\AdobeIms\Exception\AdobeImsOrganizationAuthorizationException;
16+
use Magento\AdobeImsApi\Api\Data\TokenResponseInterface;
17+
use Magento\AdobeImsApi\Api\Data\TokenResponseInterfaceFactory;
1618
use Magento\AdobeImsApi\Api\GetProfileInterface;
1719
use Magento\AdobeImsApi\Api\GetTokenInterface;
1820
use Magento\AdobeImsApi\Api\OrganizationMembershipInterface;
1921
use Magento\Framework\App\RequestInterface;
2022
use Magento\Framework\Exception\AuthenticationException;
21-
use Magento\AdminAdobeIms\Api\SaveImsUserInterface;
23+
use Magento\Framework\Exception\AuthorizationException;
2224

2325
/**
2426
* Adobe IMS Auth Model for getting Admin Token
@@ -28,6 +30,7 @@
2830
class AdobeImsAdminTokenUserService
2931
{
3032
private const ADOBE_IMS_MODULE_NAME = 'adobe_ims_auth';
33+
private const AUTHORIZATION_METHOD_HEADER_BEARER = 'bearer';
3134

3235
/**
3336
* @var ImsConfig
@@ -64,6 +67,11 @@ class AdobeImsAdminTokenUserService
6467
*/
6568
private RequestInterface $request;
6669

70+
/**
71+
* @var TokenResponseInterfaceFactory
72+
*/
73+
private TokenResponseInterfaceFactory $tokenResponseFactory;
74+
6775
/**
6876
* @var SaveImsUserInterface
6977
*/
@@ -77,6 +85,7 @@ class AdobeImsAdminTokenUserService
7785
* @param RequestInterface $request
7886
* @param GetTokenInterface $token
7987
* @param GetProfileInterface $profile
88+
* @param TokenResponseInterfaceFactory $tokenResponseFactory
8089
* @param SaveImsUserInterface $saveImsUser
8190
*/
8291
public function __construct(
@@ -87,6 +96,7 @@ public function __construct(
8796
RequestInterface $request,
8897
GetTokenInterface $token,
8998
GetProfileInterface $profile,
99+
TokenResponseInterfaceFactory $tokenResponseFactory,
90100
SaveImsUserInterface $saveImsUser
91101
) {
92102
$this->adminImsConfig = $adminImsConfig;
@@ -96,6 +106,7 @@ public function __construct(
96106
$this->request = $request;
97107
$this->token = $token;
98108
$this->profile = $profile;
109+
$this->tokenResponseFactory = $tokenResponseFactory;
99110
$this->saveImsUser = $saveImsUser;
100111
}
101112

@@ -107,33 +118,23 @@ public function __construct(
107118
* @throws AdobeImsAuthorizationException
108119
* @throws AdobeImsOrganizationAuthorizationException
109120
* @throws AuthenticationException
121+
* @throws AuthorizationException
110122
*/
111123
public function processLoginRequest(bool $isReauthorize = false): void
112124
{
113-
if ($this->adminImsConfig->enabled() && $this->request->getParam('code')
125+
if ($this->adminImsConfig->enabled()
114126
&& $this->request->getModuleName() === self::ADOBE_IMS_MODULE_NAME) {
115127
try {
116-
$code = $this->request->getParam('code');
117-
118-
//get token from response
119-
$tokenResponse = $this->token->getTokenResponse($code);
120-
$accessToken = $tokenResponse->getAccessToken();
121-
122-
//get profile info to check email
123-
$profile = $this->profile->getProfile($accessToken);
124-
if (empty($profile['email'])) {
125-
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
126-
}
127-
128-
//check membership in organization
129-
$this->organizationMembership->checkOrganizationMembership($accessToken);
130-
131-
if ($isReauthorize) {
132-
$this->adminReauthProcessService->execute($tokenResponse);
128+
if ($this->request->getHeader('Authorization')) {
129+
$tokenResponse = $this->getRequestedToken();
130+
} elseif ($this->request->getParam('code')) {
131+
$code = $this->request->getParam('code');
132+
$tokenResponse = $this->token->getTokenResponse($code);
133133
} else {
134-
$this->saveImsUser->save($profile);
135-
$this->adminLoginProcessService->execute($tokenResponse, $profile);
134+
throw new AuthenticationException(__('Unable to get Access Token. Please try again.'));
136135
}
136+
137+
$this->getLoggedIn($isReauthorize, $tokenResponse);
137138
} catch (AdobeImsAuthorizationException $e) {
138139
throw new AdobeImsAuthorizationException(
139140
__('You don\'t have access to this Commerce instance')
@@ -147,4 +148,58 @@ public function processLoginRequest(bool $isReauthorize = false): void
147148
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
148149
}
149150
}
151+
152+
/**
153+
* Get requested token using Authorization header
154+
*
155+
* @return TokenResponseInterface
156+
* @throws AuthenticationException
157+
*/
158+
private function getRequestedToken(): TokenResponseInterface
159+
{
160+
$authorizationHeaderValue = $this->request->getHeader('Authorization');
161+
if (!$authorizationHeaderValue) {
162+
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
163+
}
164+
165+
$headerPieces = explode(" ", $authorizationHeaderValue);
166+
if (count($headerPieces) !== 2) {
167+
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
168+
}
169+
170+
$tokenType = strtolower($headerPieces[0]);
171+
if ($tokenType !== self::AUTHORIZATION_METHOD_HEADER_BEARER) {
172+
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
173+
}
174+
175+
$tokenResponse['access_token'] = $headerPieces[1];
176+
return $this->tokenResponseFactory->create(['data' => $tokenResponse]);
177+
}
178+
179+
/**
180+
* Responsible for logging in to Admin Panel
181+
*
182+
* @param bool $isReauthorize
183+
* @param TokenResponseInterface $tokenResponse
184+
* @return void
185+
* @throws AdobeImsAuthorizationException
186+
* @throws AuthenticationException
187+
* @throws AuthorizationException
188+
*/
189+
private function getLoggedIn(bool $isReauthorize, TokenResponseInterface $tokenResponse): void
190+
{
191+
$profile = $this->profile->getProfile($tokenResponse->getAccessToken());
192+
if (empty($profile['email'])) {
193+
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
194+
}
195+
196+
$this->organizationMembership->checkOrganizationMembership($tokenResponse->getAccessToken());
197+
198+
if ($isReauthorize) {
199+
$this->adminReauthProcessService->execute($tokenResponse);
200+
} else {
201+
$this->saveImsUser->save($profile);
202+
$this->adminLoginProcessService->execute($tokenResponse, $profile);
203+
}
204+
}
150205
}

0 commit comments

Comments
 (0)