This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge magento/2.3-develop into magento-epam/EPAM-PR-81
- Loading branch information
Showing
7 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
app/code/Magento/Cookie/Block/DataProviders/SessionConfig.php
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,45 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Cookie\Block\DataProviders; | ||
|
||
use Magento\Framework\Session\Config\ConfigInterface; | ||
use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
|
||
/** | ||
* Provide cookie configuration | ||
*/ | ||
class SessionConfig implements ArgumentInterface | ||
{ | ||
/** | ||
* Session config | ||
* | ||
* @var ConfigInterface | ||
*/ | ||
private $sessionConfig; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ConfigInterface $sessionConfig | ||
*/ | ||
public function __construct( | ||
ConfigInterface $sessionConfig | ||
) { | ||
$this->sessionConfig = $sessionConfig; | ||
} | ||
/** | ||
* Get session.cookie_secure | ||
* | ||
* @return bool | ||
* @SuppressWarnings(PHPMD.BooleanGetMethodName) | ||
*/ | ||
public function getCookieSecure() | ||
{ | ||
return $this->sessionConfig->getCookieSecure(); | ||
} | ||
} |
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,18 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceContainer name="after.body.start"> | ||
<block class="Magento\Framework\View\Element\Js\Cookie" name="cookie_config" template="Magento_Cookie::html/cookie.phtml"> | ||
<arguments> | ||
<argument name="session_config" xsi:type="object">Magento\Cookie\Block\DataProviders\SessionConfig</argument> | ||
</arguments> | ||
</block> | ||
</referenceContainer> | ||
</body> | ||
</page> |
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,10 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
var config = { | ||
paths: { | ||
'jquery/jquery-storageapi': 'Magento_Cookie/js/jquery.storageapi.extended' | ||
} | ||
}; |
17 changes: 17 additions & 0 deletions
17
app/code/Magento/Cookie/view/base/templates/html/cookie.phtml
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,17 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Cookie settings initialization script | ||
* | ||
* @var $block \Magento\Framework\View\Element\Js\Cookie | ||
*/ | ||
?> | ||
|
||
<script> | ||
window.cookiesConfig = window.cookiesConfig || {}; | ||
window.cookiesConfig.secure = <?= /* @noEscape */ $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false' ?>; | ||
</script> |
69 changes: 69 additions & 0 deletions
69
app/code/Magento/Cookie/view/base/web/js/jquery.storageapi.extended.js
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,69 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'jquery', | ||
'jquery/jquery.cookie', | ||
'jquery/jquery.storageapi.min' | ||
], function ($) { | ||
'use strict'; | ||
|
||
/** | ||
* | ||
* @param {Object} storage | ||
* @private | ||
*/ | ||
function _extend(storage) { | ||
$.extend(storage, { | ||
_secure: window.cookiesConfig ? window.cookiesConfig.secure : false, | ||
|
||
/** | ||
* Set value under name | ||
* @param {String} name | ||
* @param {String} value | ||
* @param {Object} [options] | ||
*/ | ||
setItem: function (name, value, options) { | ||
var _default = { | ||
expires: this._expires, | ||
path: this._path, | ||
domain: this._domain, | ||
secure: this._secure | ||
}; | ||
|
||
$.cookie(this._prefix + name, value, $.extend(_default, options || {})); | ||
}, | ||
|
||
/** | ||
* Set default options | ||
* @param {Object} c | ||
* @returns {storage} | ||
*/ | ||
setConf: function (c) { | ||
if (c.path) { | ||
this._path = c.path; | ||
} | ||
|
||
if (c.domain) { | ||
this._domain = c.domain; | ||
} | ||
|
||
if (c.expires) { | ||
this._expires = c.expires; | ||
} | ||
|
||
if (typeof c.secure !== 'undefined') { | ||
this._secure = c.secure; | ||
} | ||
|
||
return this; | ||
} | ||
}); | ||
} | ||
|
||
if (window.cookieStorage) { | ||
_extend(window.cookieStorage); | ||
} | ||
}); |
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