-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Backend Security key broken for controllers with frontname not equal to route ID #7557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@AlexandreKhayrullin, thank you for your report. |
This ticket has been marked as Thank you for collaboration. |
I have a commit that I'm testing, please don't close this. |
…nstructor parameter (magento#7557)
Hi @AlexandreKhayrullin. Thank you for your report.
The fix will be available with the upcoming 2.3.0 release. |
…nstructor parameter (magento#7557)
Hi @AlexandreKhayrullin. Thank you for your report.
The fix will be available with the upcoming 2.2.8 release. |
Fix is wrong in 2.2.8. code in 2.3 |
Had this issue after upgrading to 2.2.8. Caused problems if the admin/startup/menu_item_id is set to redirect to a specific page after login, I was unable to access any of the adminhtml routes and was redirected back to the page defined in admin/startup/menu_item_id. |
Definitely still broken in 2.2.8 - can this be re-opened @sidolov ? |
Hi @chrisputnam9 , yes, we should reopen it if the issue still reproducing |
Still is being reproduced on 2.3.1. I`ll reopen and fix it when I have some time. |
Hi @novikor. Thank you for working on this issue.
|
PR_L3_05_04_2022
2024, Magento 2.4.6-p6 - same dam issue! The issue is reproducible when creating urls from the UI Components. Example <column name="download" class="Vendor\Name\Ui\Component\Listing\Columns\Download">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="label" xsi:type="string" translate="true">Download Link</item>
</item>
</argument>
</column> <?php
declare(strict_types=1);
namespace Vendor\Name\Ui\Component\Listing\Columns;
use Magento\Framework\UrlInterface;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\View\Element\UiComponentFactory;
use Vendor\Name\Data\QueueInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
class Download extends Column
{
/**
* @var UrlInterface
*/
private $urlBuilder;
private const URL_PATH_EDIT = 'order_history/export/download';
/**
* Download constructor.
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->urlBuilder = $urlBuilder;
}
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource): array
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
$name = $this->getData('name');
if (isset($item[QueueInterface::IS_GENERATED]) && $item[QueueInterface::IS_GENERATED] == 1) {
$item[$name] = html_entity_decode(sprintf(
"<a href='%s' target='_blank'>%s</a>",
$this->urlBuilder->getUrl(
self::URL_PATH_EDIT,
['filename' => $item['filename']]
),
__('Download')
));
} else {
$item[$name] = '';
}
}
}
return $dataSource;
}
} <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="digital_order_history" frontName="order_history">
<module name="Vendor_Name" before="Magento_Backend" />
</route>
</router>
</config> When adding the custom URL in the admin menu, for example, it works w/o problems. <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add
id="Vendor_Name::order_history_export"
title="Export Queue"
module="Vendor_Name"
sortOrder="20"
parent="Vendor_Name::order_history_operation"
action="order_history/export/queue"
resource="Magento_Sales::sales_order"
/>
</menu>
</config>
cc @sidolov |
Yes the problem is with \Magento\Backend\Model\Url::getUrl() uses frontName for secretKey generation and when we want to call the controller action secretKey validation runs with router id , so mismatch happens. The only solution is to use same id and frontName at backend :\ good to know |
Preconditions
The Magento used is the "develop" branch.
PHP: PHP 7.0.10-1+deb.sury.org~xenial+1
Steps to reproduce
Expected result
Actual result
After a debugging session, it appears that the security key is incorrectly generated during either the creation of backend URLs or the security key validation.
If you place a breakpoint at the last line of \Magento\Backend\Model\Url::getSecretKey(), you'll notice the following discrepancy:
The text was updated successfully, but these errors were encountered: