-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Session\ConfigInterface plugin for PHPSESSID removed PHPSESSID fron config.xml
- Loading branch information
1 parent
c3f0885
commit b88ebce
Showing
9 changed files
with
190 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
class SameSite | ||
{ | ||
/** | ||
* Return options array | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Veriteworks\CookieFix\Plugin\Session; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Session\Config; | ||
use Magento\Framework\Session\Config\ConfigInterface; | ||
use Magento\Store\Model\ScopeInterface; | ||
use Magento\Framework\HTTP\Header; | ||
use Veriteworks\CookieFix\Validator\SameSite; | ||
|
||
class ModifySameSite | ||
{ | ||
public const CONFIG_PATH = 'web/cookie/samesite'; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
/** | ||
* @var SameSite | ||
*/ | ||
private $validator; | ||
/** | ||
* @var Header | ||
*/ | ||
private $header; | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param Header $header | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param SameSite $validator | ||
*/ | ||
public function __construct( | ||
Header $header, | ||
ScopeConfigInterface $scopeConfig, | ||
SameSite $validator | ||
) { | ||
$this->validator = $validator; | ||
$this->header = $header; | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
/** | ||
* Modify samesite attribute | ||
* | ||
* @param ConfigInterface $subject | ||
* @param string $cookieSameSite | ||
* @return array | ||
*/ | ||
public function beforeSetCookieSameSite(ConfigInterface $subject, string $cookieSameSite = 'Lax'): array | ||
{ | ||
$agent = $this->header->getHttpUserAgent(); | ||
$sameSite = $this->validator->shouldSendSameSiteNone($agent); | ||
if ($sameSite === false) { | ||
$cookieSameSite = 'None'; | ||
} else { | ||
$config = $this->scopeConfig->getValue(self::CONFIG_PATH, ScopeInterface::SCOPE_STORE); | ||
if ($config !== $cookieSameSite) { | ||
$cookieSameSite = ucfirst($config); | ||
} | ||
} | ||
|
||
return [$cookieSameSite]; | ||
} | ||
} |
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.