-
-
Save magecommerce/3bdc6eac6e77a028c55d067c96489591 to your computer and use it in GitHub Desktop.
Revisions
-
ananth-iyer revised this gist
Jun 18, 2020 . 2 changed files with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ <?php namespace Vendor\Module\Plugin; class CsrfValidatorSkip { @@ -15,9 +15,14 @@ public function aroundValidate( $request, $action ) { /* Magento 2.1.x, 2.2.x */ if ($request->getModuleName() == 'Your_Module_frontName_Here') { return; // Skip CSRF check } /* Magento 2.3.x */ if (strpos($request->getOriginalPathInfo(), 'Add_Controller_frontName') !== false) { return; // Skip CSRF check } $proceed($request, $action); // Proceed Magento 2 core functionalities } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Framework\App\Request\CsrfValidator"> <plugin name="csrf_validator_skip" type="Vendor\Module\Plugin\CsrfValidatorSkip" /> </type> </config> -
ananth-iyer created this gist
Mar 27, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ <?php namespace Module\Vendor\Plugin; class CsrfValidatorSkip { /** * @param \Magento\Framework\App\Request\CsrfValidator $subject * @param \Closure $proceed * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\ActionInterface $action */ public function aroundValidate( $subject, \Closure $proceed, $request, $action ) { if ($request->getModuleName() == 'Your_Module_frontName_Here') { return; // Skip CSRF check } $proceed($request, $action); // Proceed Magento 2 core functionalities } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Framework\App\Request\CsrfValidator"> <plugin name="csrf_validator_skip" type="Module\Vendor\Plugin\CsrfValidatorSkip" /> </type> </config>