Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Security] moved Security classes out of DoctrineBundle, cleaned-up S…
…ecurityExtension accordingly Note that this commit removes the built-in support for MongoDB user providers. This code can be moved back in once there is a stable release for MongoDB, but for now you have to set-up that user provider just like you would set-up any custom user provider: security: providers: document_provider: id: my.mongo.provider
- Loading branch information
1 parent
dfd9218
commit 82c6844
Showing
9 changed files
with
148 additions
and
92 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
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
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
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
66 changes: 66 additions & 0 deletions
66
src/Symfony/Component/Security/Acl/Domain/AclCollectionCache.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,66 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Acl\Domain; | ||
|
||
use Symfony\Component\Security\Acl\Model\AclProviderInterface; | ||
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; | ||
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; | ||
|
||
/** | ||
* This service caches ACLs for an entire collection of objects. | ||
* | ||
* @author Johannes M. Schmitt <schmittjoh@gmail.com> | ||
*/ | ||
class AclCollectionCache | ||
{ | ||
protected $aclProvider; | ||
protected $objectIdentityRetrievalStrategy; | ||
protected $securityIdentityRetrievalStrategy; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param AclProviderInterface $aclProvider | ||
* @param ObjectIdentityRetrievalStrategy $oidRetrievalStrategy | ||
* @param SecurityIdentityRetrievalStrategy $sidRetrievalStrategy | ||
* @return void | ||
*/ | ||
public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy) | ||
{ | ||
$this->aclProvider = $aclProvider; | ||
$this->objectIdentityRetrievalStrategy = $oidRetrievalStrategy; | ||
$this->securityIdentityRetrievalStrategy = $sidRetrievalStrategy; | ||
} | ||
|
||
/** | ||
* Batch loads ACLs for an entire collection; thus, it reduces the number | ||
* of required queries considerably. | ||
* | ||
* @param mixed $collection anything that can be passed to foreach() | ||
* @param array $tokens an array of TokenInterface implementations | ||
* @return void | ||
*/ | ||
public function cache($collection, array $tokens = array()) | ||
{ | ||
$sids = array(); | ||
foreach ($tokens as $token) { | ||
$sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token)); | ||
} | ||
|
||
$oids = array(); | ||
foreach ($collection as $domainObject) { | ||
$oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject); | ||
} | ||
|
||
$this->aclProvider->findAcls($oids, $sids); | ||
} | ||
} |
Oops, something went wrong.