Skip to content

Commit d3eb48a

Browse files
Ashish.Kumar18Ashish.Kumar18
authored andcommitted
selector changes
2 parents 2bd2d0a + 631893c commit d3eb48a

File tree

594 files changed

+19774
-10749
lines changed

Some content is hidden

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

594 files changed

+19774
-10749
lines changed

.github/ISSUE_TEMPLATE/developer-experience-issue.md

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Developer experience issue
2+
description: Issues related to customization, extensibility, modularity
3+
labels: ['Triage: Dev.Experience']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Please read [our guidelines](https://developer.adobe.com/commerce/contributor/guides/code-contributions/#report-an-issue) before submitting the issue.
9+
- type: textarea
10+
attributes:
11+
label: Summary
12+
description: |
13+
Describe the issue you are experiencing.
14+
Include general information, error messages, environments, and so on.
15+
validations:
16+
required: true
17+
- type: textarea
18+
attributes:
19+
label: Examples
20+
description: |
21+
Provide code examples or a patch with a test (recommended) to clearly indicate the problem.
22+
validations:
23+
required: true
24+
- type: textarea
25+
attributes:
26+
label: Proposed solution
27+
description: |
28+
Suggest your potential solutions for this issue.
29+
- type: textarea
30+
attributes:
31+
label: Release note
32+
description: |
33+
Help us to provide meaningful release notes to the community.
34+
- type: checkboxes
35+
attributes:
36+
label: Triage and priority
37+
description: |
38+
Provide [Severity](https://developer.adobe.com/commerce/contributor/guides/code-contributions/#community-backlog-priority) assessment for the Issue as a Reporter.
39+
This information helps us during the Confirmation and Issue triage processes.
40+
options:
41+
- label: 'Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._'
42+
- label: 'Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._'
43+
- label: 'Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._'
44+
- label: 'Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._'
45+
- label: 'Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._'

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Feature request
2+
description: Report to https://github.com/magento/community-features
3+
labels: ['feature request']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Important: This repository is intended only for Magento 2 Technical Issues.
9+
Enter Feature Requests at https://github.com/magento/community-features.
10+
Project stakeholders monitor and manage requests.
11+
Feature requests entered using this form may be moved to the forum.
12+
- type: textarea
13+
attributes:
14+
label: Description
15+
description: |
16+
Describe the feature you would like to add.
17+
validations:
18+
required: true
19+
- type: textarea
20+
attributes:
21+
label: Expected behavior
22+
description: |
23+
What is the expected behavior of this feature?
24+
How is it going to work?
25+
validations:
26+
required: true
27+
- type: textarea
28+
attributes:
29+
label: Benefits
30+
description: |
31+
How do you think this feature would improve Magento?
32+
- type: textarea
33+
attributes:
34+
label: Additional information
35+
description: |
36+
What other information can you provide about the desired feature?
37+
- type: textarea
38+
attributes:
39+
label: Release note
40+
description: |
41+
Help us to provide meaningful release notes to the community.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AdminAdobeIms\Api;
9+
10+
use Magento\Framework\Exception\CouldNotSaveException;
11+
12+
/**
13+
* Interface SaveImsUserInterface
14+
* Save Ims User & Role
15+
*/
16+
interface SaveImsUserInterface
17+
{
18+
/**
19+
* Add Admin Adobe IMS User with Default Role i.e "Adobe Ims" & No Permissions
20+
*
21+
* @param array $profile
22+
* @return void
23+
* @throws CouldNotSaveException
24+
*/
25+
public function save(array $profile): void;
26+
}

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

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +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;
23+
use Magento\Framework\Exception\AuthorizationException;
2124

2225
/**
2326
* Adobe IMS Auth Model for getting Admin Token
@@ -27,6 +30,7 @@
2730
class AdobeImsAdminTokenUserService
2831
{
2932
private const ADOBE_IMS_MODULE_NAME = 'adobe_ims_auth';
33+
private const AUTHORIZATION_METHOD_HEADER_BEARER = 'bearer';
3034

3135
/**
3236
* @var ImsConfig
@@ -63,6 +67,16 @@ class AdobeImsAdminTokenUserService
6367
*/
6468
private RequestInterface $request;
6569

70+
/**
71+
* @var TokenResponseInterfaceFactory
72+
*/
73+
private TokenResponseInterfaceFactory $tokenResponseFactory;
74+
75+
/**
76+
* @var SaveImsUserInterface
77+
*/
78+
private SaveImsUserInterface $saveImsUser;
79+
6680
/**
6781
* @param ImsConfig $adminImsConfig
6882
* @param OrganizationMembershipInterface $organizationMembership
@@ -71,6 +85,8 @@ class AdobeImsAdminTokenUserService
7185
* @param RequestInterface $request
7286
* @param GetTokenInterface $token
7387
* @param GetProfileInterface $profile
88+
* @param TokenResponseInterfaceFactory $tokenResponseFactory
89+
* @param SaveImsUserInterface $saveImsUser
7490
*/
7591
public function __construct(
7692
ImsConfig $adminImsConfig,
@@ -79,7 +95,9 @@ public function __construct(
7995
AdminReauthProcessService $adminReauthProcessService,
8096
RequestInterface $request,
8197
GetTokenInterface $token,
82-
GetProfileInterface $profile
98+
GetProfileInterface $profile,
99+
TokenResponseInterfaceFactory $tokenResponseFactory,
100+
SaveImsUserInterface $saveImsUser
83101
) {
84102
$this->adminImsConfig = $adminImsConfig;
85103
$this->organizationMembership = $organizationMembership;
@@ -88,6 +106,8 @@ public function __construct(
88106
$this->request = $request;
89107
$this->token = $token;
90108
$this->profile = $profile;
109+
$this->tokenResponseFactory = $tokenResponseFactory;
110+
$this->saveImsUser = $saveImsUser;
91111
}
92112

93113
/**
@@ -98,32 +118,23 @@ public function __construct(
98118
* @throws AdobeImsAuthorizationException
99119
* @throws AdobeImsOrganizationAuthorizationException
100120
* @throws AuthenticationException
121+
* @throws AuthorizationException
101122
*/
102123
public function processLoginRequest(bool $isReauthorize = false): void
103124
{
104-
if ($this->adminImsConfig->enabled() && $this->request->getParam('code')
125+
if ($this->adminImsConfig->enabled()
105126
&& $this->request->getModuleName() === self::ADOBE_IMS_MODULE_NAME) {
106127
try {
107-
$code = $this->request->getParam('code');
108-
109-
//get token from response
110-
$tokenResponse = $this->token->getTokenResponse($code);
111-
$accessToken = $tokenResponse->getAccessToken();
112-
113-
//get profile info to check email
114-
$profile = $this->profile->getProfile($accessToken);
115-
if (empty($profile['email'])) {
116-
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
117-
}
118-
119-
//check membership in organization
120-
$this->organizationMembership->checkOrganizationMembership($accessToken);
121-
122-
if ($isReauthorize) {
123-
$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);
124133
} else {
125-
$this->adminLoginProcessService->execute($tokenResponse, $profile);
134+
throw new AuthenticationException(__('Unable to get Access Token. Please try again.'));
126135
}
136+
137+
$this->getLoggedIn($isReauthorize, $tokenResponse);
127138
} catch (AdobeImsAuthorizationException $e) {
128139
throw new AdobeImsAuthorizationException(
129140
__('You don\'t have access to this Commerce instance')
@@ -137,4 +148,58 @@ public function processLoginRequest(bool $isReauthorize = false): void
137148
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
138149
}
139150
}
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+
}
140205
}

0 commit comments

Comments
 (0)