Skip to content

Conversation

@Neos2007
Copy link
Contributor

Preconditions

Magento 2.2 have multiple admin user roles with access restrictions to some resources. Role has access to cart price rules, but it restricted to catalog rules rules.

Problem

When admin user with role mentioned above tried in edit/new cart price rule, in conditions settings add “SKU” condition, and then select products from loaded product grid – all grid navigation, sorting and filtering operations will lead to “403” redirect.

Reason
When magento loaded products grid for selecting product sku for cart price rules it use controller action which is inherited from similar one form CatalogRule module, this controller render its block Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Sku (which generate product grid HTML and JavaScript). This block method “getGridUrl” generates urls with route 'catalog_rule/*/chooser', so all requests for updating products grid data will lead to CatalogRule module controller. But current user has no access to CatalogRule routes so it get 403 response.



Solution

Modify method Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Sku::getGridUrl() method. Change route parameter which it pass in “getUrl” method from “catalog_rule//chooser” to “/*/chooser”.

…::getGridUrl() method.

Route "module" part replaced by asterix symbol, which allow correct use this bock in "rules" logic in other modules
(generate grid urls related to their own controllers which can fix some ACL conflicts).
@magento-engcom-team
Copy link
Contributor

@Neos2007 thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@VladimirZaets
Copy link
Contributor

Hi @Neos2007 , thank you for collaboration.
Can you please describe steps to reproduce this issue in details?

@nuzil
Copy link
Contributor

nuzil commented Apr 30, 2018

Hello @VladimirZaets
To reproduce this issue:

  • GoTo Magento Admin
  • Create New User Role and grant to it permission for Shopping Cart rules, but NOT for Catalog Price Rules
  • Create New user and assign to created role
  • Login to Admin with new user
  • Go to Shopping Cart rules
  • Go to Conditions Section and create sub selection of products with "SKU is:" and try to choose products
  • On appeared Product Grid try to navigate by Pages or Make a search.
  • You will be redirected to Permissions Denied page

@VladimirZaets
Copy link
Contributor

VladimirZaets commented May 2, 2018

@Neos2007 thanks! I will to test it and process the PR

magento-team pushed a commit that referenced this pull request May 3, 2018
… rule edit page for user which has no access to CatalogRule module #14886
@magento-engcom-team magento-engcom-team merged commit 8c8df93 into magento:2.2-develop May 3, 2018
@magento-engcom-team
Copy link
Contributor

Hi @Neos2007. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.2.5 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants