Skip to content

Commit

Permalink
Merge branch '2.2-develop-mainline' into magento-2.2-develop-issue-21499
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bystritsky committed Apr 4, 2019
2 parents 5a73640 + 9c4350c commit f4a83f6
Show file tree
Hide file tree
Showing 772 changed files with 15,943 additions and 5,269 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ atlassian*
/pub/media/import/*
!/pub/media/import/.htaccess
/pub/media/logo/*
/pub/media/custom_options/*
!/pub/media/custom_options/.htaccess
/pub/media/theme/*
/pub/media/theme_customization/*
!/pub/media/theme_customization/.htaccess
Expand Down
11 changes: 11 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

############################################
## default index file
## Specifies option, to use methods arguments in backtrace or not
SetEnv MAGE_DEBUG_SHOW_ARGS 1

DirectoryIndex index.php

Expand Down Expand Up @@ -364,6 +366,15 @@
Require all denied
</IfVersion>
</Files>
<Files .user.ini>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>

# For 404s and 403s that aren't handled by the application, show plain 404 response
ErrorDocument 404 /pub/errors/404.php
Expand Down
9 changes: 9 additions & 0 deletions .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@
Require all denied
</IfVersion>
</Files>
<Files .user.ini>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>

# For 404s and 403s that aren't handled by the application, show plain 404 response
ErrorDocument 404 /pub/errors/404.php
Expand Down
473 changes: 473 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Environment initialization
*/
error_reporting(E_ALL);
stream_wrapper_unregister('phar');
#ini_set('display_errors', 1);

/* PHP version validation */
Expand Down
23 changes: 15 additions & 8 deletions app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Magento\AdminNotification\Block\Grid\Renderer;

/**
* Renderer class for action in the admin notifications grid.
*/
class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
Expand Down Expand Up @@ -37,19 +40,23 @@ public function __construct(
*/
public function render(\Magento\Framework\DataObject $row)
{
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' .
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
$this->escapeUrl($row->getUrl())
. '">' .
__('Read Details') . '</a>' : '';

$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
'*/*/markAsRead/',
['_current' => true, 'id' => $row->getId()]
) . '">' . __(
'Mark as Read'
) . '</a>' : '';
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' .
$this->getUrl(
'*/*/markAsRead/',
['_current' => true, 'id' => $row->getId()]
) . '">' . __(
'Mark as Read'
) . '</a>' : '';

$encodedUrl = $this->_urlHelper->getEncodedUrl();
return sprintf(
'%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>',
'%s%s<a class="action-delete" href="%s" onclick="deleteConfirm(\'%s\', this.href, {data: {}});' .
' return false;">%s</a>',
$readDetailsHtml,
$markAsReadHtml,
$this->getUrl(
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lib-libxml": "*"
},
"type": "magento2-module",
"version": "100.2.5",
"version": "100.2.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AdditionalCommentTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment', 'getLabel'])
->setMethods(['getComment', 'getLabel', 'getHtmlId', 'getName'])
->disableOriginalConstructor()
->getMock();
$this->contextMock = $this->getMockBuilder(Context::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment'])
->setMethods(['getComment', 'getHtmlId', 'getName'])
->disableOriginalConstructor()
->getMock();
$this->contextMock = $this->getMockBuilder(Context::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment'])
->setMethods(['getComment', 'getHtmlId', 'getName'])
->disableOriginalConstructor()
->getMock();
$this->formMock = $this->getMockBuilder(Form::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VerticalTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment', 'getLabel', 'getHint'])
->setMethods(['getComment', 'getLabel', 'getHint', 'getHtmlId', 'getName'])
->disableOriginalConstructor()
->getMock();
$this->contextMock = $this->getMockBuilder(Context::class)
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
"version": "100.2.4",
"version": "100.2.5",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
9 changes: 5 additions & 4 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,16 @@ public function setResponseData(array $postData)
public function validateResponse()
{
$response = $this->getResponse();
//md5 check
if (!$this->getConfigData('trans_md5')
|| !$this->getConfigData('login')
|| !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login'))
$hashConfigKey = !empty($response->getData('x_SHA2_Hash')) ? 'signature_key' : 'trans_md5';

//hash check
if (!$response->isValidHash($this->getConfigData($hashConfigKey), $this->getConfigData('login'))
) {
throw new \Magento\Framework\Exception\LocalizedException(
__('The transaction was declined because the response hash validation failed.')
);
}

return true;
}

Expand Down
116 changes: 103 additions & 13 deletions app/code/Magento/Authorizenet/Model/Directpost/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Authorizenet\Model\Directpost;

use Magento\Authorizenet\Model\Request as AuthorizenetRequest;
use Magento\Framework\Intl\DateTimeFactory;

/**
* Authorize.net request model for DirectPost model
Expand All @@ -18,9 +19,33 @@ class Request extends AuthorizenetRequest
*/
protected $_transKey = null;

/**
* Hexadecimal signature key.
*
* @var string
*/
private $signatureKey = '';

/**
* @var DateTimeFactory
*/
private $dateTimeFactory;

/**
* @param DateTimeFactory $dateTimeFactory
* @param array $data
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
array $data = []
) {
$this->dateTimeFactory = $dateTimeFactory;
parent::__construct($data);
}

/**
* Return merchant transaction key.
* Needed to generate sign.
* Needed to generate MD5 sign.
*
* @return string
*/
Expand All @@ -31,7 +56,7 @@ protected function _getTransactionKey()

/**
* Set merchant transaction key.
* Needed to generate sign.
* Needed to generate MD5 sign.
*
* @param string $transKey
* @return $this
Expand All @@ -43,7 +68,7 @@ protected function _setTransactionKey($transKey)
}

/**
* Generates the fingerprint for request.
* Generates the MD5 fingerprint for request.
*
* @param string $merchantApiLoginId
* @param string $merchantTransactionKey
Expand All @@ -63,7 +88,7 @@ public function generateRequestSign(
) {
return hash_hmac(
"md5",
$merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode,
$merchantApiLoginId . '^' . $fpSequence . '^' . $fpTimestamp . '^' . $amount . '^' . $currencyCode,
$merchantTransactionKey
);
}
Expand All @@ -85,6 +110,7 @@ public function setConstantData(\Magento\Authorizenet\Model\Directpost $paymentM
->setXRelayUrl($paymentMethod->getRelayUrl());

$this->_setTransactionKey($paymentMethod->getConfigData('trans_key'));
$this->setSignatureKey($paymentMethod->getConfigData('signature_key'));
return $this;
}

Expand Down Expand Up @@ -168,17 +194,81 @@ public function setDataFromOrder(
*/
public function signRequestData()
{
$fpTimestamp = time();
$hash = $this->generateRequestSign(
$this->getXLogin(),
$this->_getTransactionKey(),
$this->getXAmount(),
$this->getXCurrencyCode(),
$this->getXFpSequence(),
$fpTimestamp
);
$fpDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
$fpTimestamp = $fpDate->getTimestamp();

if (!empty($this->getSignatureKey())) {
$hash = $this->generateSha2RequestSign(
$this->getXLogin(),
$this->getSignatureKey(),
$this->getXAmount(),
$this->getXCurrencyCode(),
$this->getXFpSequence(),
$fpTimestamp
);
} else {
$hash = $this->generateRequestSign(
$this->getXLogin(),
$this->_getTransactionKey(),
$this->getXAmount(),
$this->getXCurrencyCode(),
$this->getXFpSequence(),
$fpTimestamp
);
}

$this->setXFpTimestamp($fpTimestamp);
$this->setXFpHash($hash);

return $this;
}

/**
* Generates the SHA2 fingerprint for request.
*
* @param string $merchantApiLoginId
* @param string $merchantSignatureKey
* @param string $amount
* @param string $currencyCode
* @param string $fpSequence An invoice number or random number.
* @param string $fpTimestamp
* @return string The fingerprint.
*/
private function generateSha2RequestSign(
$merchantApiLoginId,
$merchantSignatureKey,
$amount,
$currencyCode,
$fpSequence,
$fpTimestamp
): string {
$message = $merchantApiLoginId . '^' . $fpSequence . '^' . $fpTimestamp . '^' . $amount . '^' . $currencyCode;

return strtoupper(hash_hmac('sha512', $message, pack('H*', $merchantSignatureKey)));
}

/**
* Return merchant hexadecimal signature key.
*
* Needed to generate SHA2 sign.
*
* @return string
*/
private function getSignatureKey(): string
{
return $this->signatureKey;
}

/**
* Set merchant hexadecimal signature key.
*
* Needed to generate SHA2 sign.
*
* @param string $signatureKey
* @return void
*/
private function setSignatureKey(string $signatureKey)
{
$this->signatureKey = $signatureKey;
}
}
Loading

0 comments on commit f4a83f6

Please sign in to comment.