Skip to content

Commit

Permalink
MAGETWO-23159: [GITHUB] Area Sessions: Magento 2 Should not Allow "ar…
Browse files Browse the repository at this point in the history
…ea-less" Sessions During an Area Aware Request #526
  • Loading branch information
Joan He committed Apr 29, 2015
1 parent 385f475 commit 5c5d60c
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 219 deletions.
7 changes: 5 additions & 2 deletions app/code/Magento/Backend/Model/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
* @param \Magento\Framework\Session\StorageInterface $storage
* @param CookieManagerInterface $cookieManager
* @param CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\State $appState
* @param \Magento\Framework\Acl\Builder $aclBuilder
* @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param \Magento\Backend\App\ConfigInterface $config
* @throws \Magento\Framework\Exception\SessionException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -75,6 +77,7 @@ public function __construct(
\Magento\Framework\Session\StorageInterface $storage,
CookieManagerInterface $cookieManager,
CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\App\State $appState,
\Magento\Framework\Acl\Builder $aclBuilder,
\Magento\Backend\Model\UrlInterface $backendUrl,
\Magento\Backend\App\ConfigInterface $config
Expand All @@ -90,9 +93,9 @@ public function __construct(
$validator,
$storage,
$cookieManager,
$cookieMetadataFactory
$cookieMetadataFactory,
$appState
);
$this->start();
}

/**
Expand Down
33 changes: 0 additions & 33 deletions app/code/Magento/Backend/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,6 @@

class Session extends \Magento\Framework\Session\SessionManager
{
/**
* @param \Magento\Framework\App\Request\Http $request
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
* @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig
* @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler
* @param \Magento\Framework\Session\ValidatorInterface $validator
* @param \Magento\Framework\Session\StorageInterface $storage
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
*/
public function __construct(
\Magento\Framework\App\Request\Http $request,
\Magento\Framework\Session\SidResolverInterface $sidResolver,
\Magento\Framework\Session\Config\ConfigInterface $sessionConfig,
\Magento\Framework\Session\SaveHandlerInterface $saveHandler,
\Magento\Framework\Session\ValidatorInterface $validator,
\Magento\Framework\Session\StorageInterface $storage,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
) {
parent::__construct(
$request,
$sidResolver,
$sessionConfig,
$saveHandler,
$validator,
$storage,
$cookieManager,
$cookieMetadataFactory
);
$this->start();
}

/**
* Skip path validation in backend area
*
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Backend/Model/Session/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ class Quote extends \Magento\Framework\Session\SessionManager
* @param \Magento\Framework\Session\StorageInterface $storage
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\State $appState
* @param CustomerRepositoryInterface $customerRepository
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param GroupManagementInterface $groupManagement
* @throws \Magento\Framework\Exception\SessionException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -99,6 +101,7 @@ public function __construct(
\Magento\Framework\Session\StorageInterface $storage,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\App\State $appState,
CustomerRepositoryInterface $customerRepository,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Sales\Model\OrderFactory $orderFactory,
Expand All @@ -118,9 +121,9 @@ public function __construct(
$validator,
$storage,
$cookieManager,
$cookieMetadataFactory
$cookieMetadataFactory,
$appState
);
$this->start();
if ($this->_storeManager->hasSingleStore()) {
$this->setStoreId($this->_storeManager->getStore(true)->getId());
}
Expand Down
10 changes: 9 additions & 1 deletion app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ protected function setUp()
'',
false
);
$appStateMock = $this->getMock(
'Magento\Framework\App\State',
[],
[],
'',
false
);
$this->storeManagerMock = $this->getMockForAbstractClass(
'Magento\Store\Model\StoreManagerInterface',
[],
Expand All @@ -201,11 +208,12 @@ protected function setUp()
'storage' => $this->storageMock,
'cookieManager' => $this->cookieManagerMock,
'cookieMetadataFactory' => $this->cookieMetadataFactoryMock,
'appState' => $appStateMock,
'customerRepository' => $this->customerRepositoryMock,
'quoteRepository' => $this->quoteRepositoryMock,
'orderFactory' => $this->orderFactoryMock,
'storeManager' => $this->storeManagerMock,
'groupManagement' => $this->groupManagementMock
'groupManagement' => $this->groupManagementMock,
],
'',
true
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
/**
* Catalog session model
*/
class Session extends \Magento\Framework\Session\Generic
class Session extends \Magento\Framework\Session\SessionManager
{
}
7 changes: 5 additions & 2 deletions app/code/Magento/Checkout/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ class Session extends \Magento\Framework\Session\SessionManager
* @param \Magento\Framework\Session\StorageInterface $storage
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\State $appState
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @throws \Magento\Framework\Exception\SessionException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -108,6 +110,7 @@ public function __construct(
\Magento\Framework\Session\StorageInterface $storage,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\App\State $appState,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Customer\Model\Session $customerSession,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
Expand All @@ -131,9 +134,9 @@ public function __construct(
$validator,
$storage,
$cookieManager,
$cookieMetadataFactory
$cookieMetadataFactory,
$appState
);
$this->start();
}

/**
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Customer/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Session extends \Magento\Framework\Session\SessionManager
* @param \Magento\Framework\Session\StorageInterface $storage
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\State $appState
* @param Share $configShare
* @param \Magento\Framework\Url\Helper\Data $coreUrl
* @param \Magento\Customer\Model\Url $customerUrl
Expand All @@ -113,6 +114,7 @@ class Session extends \Magento\Framework\Session\SessionManager
* @param \Magento\Framework\App\Http\Context $httpContext
* @param CustomerRepositoryInterface $customerRepository
* @param GroupManagementInterface $groupManagement
* @throws \Magento\Framework\Exception\SessionException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -124,6 +126,7 @@ public function __construct(
\Magento\Framework\Session\StorageInterface $storage,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\App\State $appState,
Config\Share $configShare,
\Magento\Framework\Url\Helper\Data $coreUrl,
\Magento\Customer\Model\Url $customerUrl,
Expand Down Expand Up @@ -154,9 +157,9 @@ public function __construct(
$validator,
$storage,
$cookieManager,
$cookieMetadataFactory
$cookieMetadataFactory,
$appState
);
$this->start();
$this->groupManagement = $groupManagement;
$this->_eventManager->dispatch('customer_session_init', ['customer_session' => $this]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Newsletter/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Newsletter session model
*/
class Session extends \Magento\Framework\Session\Generic
class Session extends \Magento\Framework\Session\SessionManager
{
/**
* Set error message
Expand Down
Loading

0 comments on commit 5c5d60c

Please sign in to comment.