Skip to content

Commit 26c5ae9

Browse files
committed
ACP2E-2969: REST API unable to make requests with slash (/) in SKU when using Oauth1
1 parent 4ec2c8b commit 26c5ae9

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use OAuth\OAuth1\Signature\SignatureInterface;
1919
use OAuth\OAuth1\Token\StdOAuth1Token;
2020
use OAuth\OAuth1\Token\TokenInterface;
21+
use Laminas\OAuth\Http\Utility as HTTPUtility;
22+
use Magento\Framework\Oauth\Helper\Signature\Hmac256;
2123

2224
/**
2325
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -56,7 +58,7 @@ public function __construct(
5658
$storage = new \OAuth\Common\Storage\Memory();
5759
}
5860
if (!isset($helper)) {
59-
$helper = new Utility();
61+
$helper = new Utility(new HTTPUtility(), new Hmac256());
6062
}
6163
if (!isset($signature)) {
6264
$signature = new \Magento\TestFramework\Authentication\Rest\OauthClient\Signature($helper, $credentials);

lib/internal/Magento/Framework/Oauth/Helper/Signature/Hmac256.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
27

38
namespace Magento\Framework\Oauth\Helper\Signature;
49

@@ -10,7 +15,7 @@ class Hmac256
1015
* Sign a request
1116
*
1217
* @param array $params
13-
* @param string $signatureMethod
18+
* @param string $algo
1419
* @param string $consumerSecret
1520
* @param string|null $tokenSecret
1621
* @param mixed $method
@@ -19,7 +24,7 @@ class Hmac256
1924
*/
2025
public function sign(
2126
array $params,
22-
string $signatureMethod,
27+
string $algo,
2328
string $consumerSecret,
2429
?string $tokenSecret = null,
2530
?string $method = null,
@@ -29,7 +34,7 @@ public function sign(
2934

3035
$binaryHash = HMACEncryption::compute(
3136
$this->assembleKey($consumerSecret, $tokenSecret),
32-
$signatureMethod,
37+
$algo,
3338
$this->getBaseSignatureString($params, $method, $url),
3439
HMACEncryption::OUTPUT_BINARY
3540
);

lib/internal/Magento/Framework/Oauth/Helper/Utility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public function sign(
4747
}
4848

4949
/**
50-
* Check if signature method is HMAC256
50+
* Check if signature method is HMAC-SHA256
5151
*
5252
* @param string $signatureMethod
5353
* @return bool
5454
*/
5555
private function isHmac256(string $signatureMethod): bool
5656
{
57-
if (strtoupper(preg_replace( '/[\W]/', '', $signatureMethod)) === 'HMAC256') {
57+
if (strtoupper(preg_replace( '/[\W]/', '', $signatureMethod)) === 'HMACSHA256') {
5858
return true;
5959
}
6060

0 commit comments

Comments
 (0)