<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
/**
* Shopware Auth component
*/
class Shopware_Components_Auth extends Enlight_Components_Auth
{
/**
* List with auth adapters
* @var array
*/
protected $_adapter = array();
/**
* Adapter that is current active - has a valid user session
* @var null
*/
protected $_baseAdapter = null; // Current active adapter
/**
* Get all adapters or certain one
*
* @param null $index
* @return array|Zend_Auth_Adapter_Interface
*/
public function getAdapter($index = null)
{
if (isset($index)) {
return $this->_adapter[$index];
}
return $this->_adapter;
}
/**
* Add adapter to list
* @param Zend_Auth_Adapter_Interface $adapter
* @return Shopware_Components_Auth
*/
public function addAdapter(Zend_Auth_Adapter_Interface $adapter)
{
$this->_adapter[] = $adapter;
return $this;
}
/**
* Login method - iterate through all adapters and check for valid account
*
* @param string $username
* @param string $password
* @return Zend_Auth_Result
*/
public function login($username, $password)
{
$result = null;
$adapters = $this->getAdapter();
foreach ($adapters as $adapter) {
$adapter->setIdentity($username);
$adapter->setCredential($password);
$result = $this->authenticate($adapter);
if ($result->isValid()) {
$this->setBaseAdapter($adapter);
return $result;
}
}
$this->setBaseAdapter(null);
return $result;
}
/**
* Set current active adapter
*
* @param $adapter
* @return \Shopware_Components_Auth
*/
public function setBaseAdapter($adapter)
{
$this->_baseAdapter = $adapter;
return $this;
}
/**
* Get current active adapter
*
* @return Zend_Auth_Adapter_Interface
*/
public function getBaseAdapter()
{
return $this->_baseAdapter;
}
/**
* Do a authentication approve with a defined adapter
*
* @param null|Zend_Auth_Adapter_Interface $adapter
* @return Zend_Auth_Result
*/
public function authenticate(Zend_Auth_Adapter_Interface $adapter = null)
{
if ($adapter == null) {
$adapter = $this->_baseAdapter;
}
$result = parent::authenticate($adapter);
// If authentication with the current adapter was succeeded, read user data from default adapter (database)
if ($result->isValid() && method_exists($this->getAdapter(0), 'getResultRowObject')) {
$user = $this->getAdapter(0)->getResultRowObject();
$this->getStorage()->write($user);
} else {
$this->getStorage()->clear();
}
return $result;
}
/**
* Refresh authentication - for example expire date -
*
* @param null|Zend_Auth_Adapter_Interface $adapter
* @return mixed
*/
public function refresh(Zend_Auth_Adapter_Interface $adapter = null)
{
if ($adapter == null) {
$adapter = $this->getBaseAdapter();
}
$result = $adapter->refresh();
if (!$result->isValid()) {
$this->getStorage()->clear();
}
return $result;
}
/**
* Get an instance from this object
* @static
* @return Shopware_Components_Auth
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Validates the given credentials of a user
*
* @param string $username
* @param string $password
* @return bool
*/
public function isPasswordValid($username, $password)
{
$storage = $this->getStorage();
$adapters = $this->getAdapter();
$this->setStorage(new Zend_Auth_Storage_NonPersistent());
foreach ($adapters as $adapter) {
$adapter->setIdentity($username);
$adapter->setCredential($password);
$result = $this->authenticate($adapter);
if ($result->isValid()) {
$this->setStorage($storage);
return true;
}
}
$this->setStorage($storage);
return false;
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| Api/ | 2016-11-07 16:02 | 287.29 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Auth/ | 2016-11-07 16:02 | 9.48 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Benchmark/ | 2016-11-07 15:59 | 2.97 KB | 76129f60960:kunden | dxwrx-rx-r | |
| CategoryHandling/ | 2016-11-07 15:59 | 6.7 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Check/ | 2016-11-07 16:02 | 137.23 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Compatibility/ | 2016-11-07 15:59 | 40.29 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Console/ | 2016-11-07 15:59 | 9.29 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Convert/ | 2016-11-07 15:59 | 21.31 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Cron/ | 2016-11-07 15:59 | 1.8 KB | 76129f60960:kunden | dxwrx-rx-r | |
| DependencyInjection/ | 2016-11-07 16:02 | 89.93 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Emotion/ | 2016-11-07 15:59 | 6.4 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Escaper/ | 2016-11-07 15:59 | 5.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Form/ | 2016-11-07 16:02 | 45.21 KB | 76129f60960:kunden | dxwrx-rx-r | |
| HttpCache/ | 2016-11-07 15:59 | 27.91 KB | 76129f60960:kunden | dxwrx-rx-r | |
| HttpClient/ | 2016-11-07 15:59 | 261.1 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Install/ | 2016-11-07 15:59 | 3.59 KB | 76129f60960:kunden | dxwrx-rx-r | |
| LegacyRequestWrapper/ | 2016-11-07 15:59 | 9.77 KB | 76129f60960:kunden | dxwrx-rx-r | |
| License/ | 2016-11-07 16:02 | 18.86 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Log/ | 2016-11-07 16:02 | 33.09 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Migrations/ | 2016-11-07 15:59 | 10.92 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Model/ | 2016-11-07 16:04 | 141.64 KB | 76129f60960:kunden | dxwrx-rx-r | |
| MultiEdit/ | 2016-11-07 16:02 | 98 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Password/ | 2016-11-07 16:02 | 18.5 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Plugin/ | 2016-11-07 16:02 | 119.2 KB | 76129f60960:kunden | dxwrx-rx-r | |
| ProductStream/ | 2016-11-07 15:59 | 19.08 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Routing/ | 2016-11-07 16:02 | 58.6 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Snippet/ | 2016-11-07 16:02 | 38.98 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Test/ | 2016-11-07 16:02 | 4.02 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Theme/ | 2016-11-07 16:02 | 130.93 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Thumbnail/ | 2016-11-07 16:02 | 21.71 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Validator/ | 2016-11-07 15:59 | 3.01 KB | 76129f60960:kunden | dxwrx-rx-r | |
| Acl.php | 2016-11-07 15:58 | 6.65 KB | 76129f60960:kunden | -xw-x----- | |
| AttributeSubscriber.php | 2016-11-07 15:58 | 4.73 KB | 76129f60960:kunden | -xw-x----- | |
| Auth.php | 2016-11-07 15:58 | 5.26 KB | 76129f60960:kunden | -xw-x----- | |
| CSRFTokenValidationException.php | 2016-11-07 15:58 | 1.08 KB | 76129f60960:kunden | -xw-x----- | |
| CSRFTokenValidator.php | 2016-11-07 15:58 | 5.52 KB | 76129f60960:kunden | -xw-x----- | |
| CSRFWhitelistAware.php | 2016-11-07 15:58 | 1.23 KB | 76129f60960:kunden | -xw-x----- | |
| CacheManager.php | 2016-11-07 15:58 | 12.56 KB | 76129f60960:kunden | -xw-x----- | |
| Config.php | 2016-11-07 15:58 | 7.9 KB | 76129f60960:kunden | -xw-x----- | |
| ConfigLoader.php | 2016-11-07 15:58 | 5.01 KB | 76129f60960:kunden | -xw-x----- | |
| ConfigWriter.php | 2016-11-07 15:58 | 4.32 KB | 76129f60960:kunden | -xw-x----- | |
| ContainerAwareEventManager.php | 2016-11-07 15:58 | 6.61 KB | 76129f60960:kunden | -xw-x----- | |
| CsvIterator.php | 2016-11-07 15:58 | 6.91 KB | 76129f60960:kunden | -xw-x----- | |
| Document.php | 2016-11-07 15:58 | 22.91 KB | 76129f60960:kunden | -xw-x----- | |
| Form.php | 2016-11-07 15:58 | 1.43 KB | 76129f60960:kunden | -xw-x----- | |
| HolidayTableUpdater.php | 2016-11-07 15:58 | 4.42 KB | 76129f60960:kunden | -xw-x----- | |
| Licence.php | 2016-11-07 15:58 | 1.25 KB | 76129f60960:kunden | -xw-x----- | |
| LicenseInstaller.php | 2016-11-07 15:58 | 3.04 KB | 76129f60960:kunden | -xw-x----- | |
| Logger.php | 2016-11-07 15:58 | 1.59 KB | 76129f60960:kunden | -xw-x----- | |
| MemoryLimit.php | 2016-11-07 15:58 | 2.04 KB | 76129f60960:kunden | -xw-x----- | |
| Modules.php | 2016-11-07 15:58 | 4.94 KB | 76129f60960:kunden | -xw-x----- | |
| NumberRangeIncrementer.php | 2016-11-07 15:58 | 2.16 KB | 76129f60960:kunden | -xw-x----- | |
| NumberRangeIncrementerInterface.php | 2016-11-07 15:58 | 1.65 KB | 76129f60960:kunden | -xw-x----- | |
| OpenSSLVerifier.php | 2016-11-07 15:58 | 2.82 KB | 76129f60960:kunden | -xw-x----- | |
| Plugin.php | 2016-11-07 15:58 | 5.31 KB | 76129f60960:kunden | -xw-x----- | |
| QueryAliasMapper.php | 2016-11-07 15:58 | 4.62 KB | 76129f60960:kunden | -xw-x----- | |
| Random.php | 2016-11-07 15:58 | 5.7 KB | 76129f60960:kunden | -xw-x----- | |
| ReflectionHelper.php | 2016-11-07 15:58 | 2.11 KB | 76129f60960:kunden | -xw-x----- | |
| SitePageMenu.php | 2016-11-07 15:58 | 5.13 KB | 76129f60960:kunden | -xw-x----- | |
| SitemapXMLRepository.php | 2016-11-07 15:58 | 10.86 KB | 76129f60960:kunden | -xw-x----- | |
| StringCompiler.php | 2016-11-07 15:58 | 4.64 KB | 76129f60960:kunden | -xw-x----- | |
| TemplateMail.php | 2016-11-07 15:58 | 7.54 KB | 76129f60960:kunden | -xw-x----- | |
| Theme.php | 2016-11-07 15:58 | 13.07 KB | 76129f60960:kunden | -xw-x----- | |
| Translation.php | 2016-11-07 15:58 | 16.25 KB | 76129f60960:kunden | -xw-x----- | |