[ACL] bug quand isGranted() n'est pas valide
Bonjour,
J'ai une erreur qui me poursuit depuis quelques temps et je ne sais pas si c'est moi qui fait quelque chose faux ou si c'est un bug.
J'ai une table avec des produits qui appartiennent à différents vendeurs ( FOSUserBundle) quand un vendeur ajoute un produit je crée des ACL comme indiqué dans la doc de symfony:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
if ('POST' === $request->getMethod()) {
$form->bindRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$product->setVendor($vendor);
$vendor->addProducts($product);
$em->persist($product);
$em->persist($vendor);
$em->flush();
//acl for the product
$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($product);
$acl = $aclProvider->createAcl($objectIdentity);
// retrieving the security identity of the page owner
$securityContext = $this->get('security.context');
$securityIdentity = UserSecurityIdentity::fromAccount($vendor);
// grant owner access Update acl
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);
//flash message success
$this->get('session')->setFlash('success', 'You have successfully added a product!');
return $this->redirect($this->generateUrl('page_show', array('username' => $vendor->getUsername())));
} |
Jusque là tout fonctionne parfaitement.... Maintenant dans un autre Controller je veux authorizer seulement le propriétaire du produit à ajouter des photos du produit. Je veux donc utiliser la fonction isGranted... J'obtenais pas mal d'erreurs et j'ai donc décidé de la tester dans cette action:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public function testAction() {
$em = $this->getDoctrine()->getEntityManager();
$securityContext = $this->get('security.context');
$product = $em->getRepository('FldProductBundle:Product')->find(11);
if (!$product) {
throw $this->createNotFoundException('Unable to find Product entity.');
}
$grant = $securityContext->isGranted('EDIT', $product);
var_dump($grant);
return new Response('salut');
} |
Tout fonctionne comme attendu quand je suis logué avec le propriétaire du produit 11 ( var_dump($grant); done boolean true et la réponse salut ;)
Maintenat quand je me logue avec quelqu'un qui n'est pas le proprio du produit 11 php semble tourner un moment ( mon portable lague un peu) et ensuite xdebug me donne cette erreur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in /.../vendor/symfony/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php on line 172
Call Stack
# Time Memory Function Location
1 0.0000 638888 {main}( ) ../app_dev.php:0
2 0.0505 2010448 Symfony\Component\HttpKernel\Kernel->handle( ) ../app_dev.php:20
3 0.0588 2640768 Symfony\Bundle\FrameworkBundle\HttpKernel->handle( ) ../bootstrap.php.cache:547
4 0.0588 2641776 Symfony\Component\HttpKernel\HttpKernel->handle( ) ../classes.php:4832
5 0.0588 2641776 Symfony\Component\HttpKernel\HttpKernel->handleRaw( ) ../classes.php:3853
6 0.2615 5471424 call_user_func_array ( ) ../classes.php:3883
7 0.2615 5471792 Fld\MediaBundle\Controller\ImageController->testAction( ) ../classes.php:3883
8 0.3607 5868128 Symfony\Component\Security\Core\SecurityContext->isGranted( ) ../ImageController.php:57
9 0.3608 5868696 Symfony\Component\Security\Core\Authorization\AccessDecisionManager->decide( ) ../classes.php:5079
10 0.3608 5868696 Symfony\Component\Security\Core\Authorization\AccessDecisionManager->decideAffirmative( ) ../classes.php:5266
11 0.3609 5868856 Symfony\Component\Security\Acl\Voter\AclVoter->vote( ) ../classes.php:5298
12 0.5432 6017584 Symfony\Component\Security\Acl\Domain\Acl->isGranted( ) ../AclVoter.php:97
13 0.5433 6017584 Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy->isGranted( ) ../Acl.php:228
14 0.5433 6017584 Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy->hasSufficientPermissions( ) ../PermissionGrantingStrategy.php:59
Variables in local scope (#14)
$ace =
&object(Symfony\Component\Security\Acl\Domain\Entry)[521]
$aces =
array
0 =>
&object(Symfony\Component\Security\Acl\Domain\Entry)[521]
$acl =
&object(Symfony\Component\Security\Acl\Domain\Acl)[523]
$administrativeMode =
boolean false
$firstRejectedAce =
null
$masks =
array
0 => int 4
1 => int 32
2 => int 64
3 => int 128
$requiredMask =
int 128
$sid =
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[508]
private 'role' => string 'IS_AUTHENTICATED_ANONYMOUSLY' (length=28)
$sids =
array
0 =>
object(Symfony\Component\Security\Acl\Domain\UserSecurityIdentity)[47]
private 'username' => string 'dada' (length=4)
private 'class' => string 'Fld\UserBundle\Entity\User' (length=26)
1 =>
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[510]
private 'role' => string 'ROLE_VENDOR' (length=11)
2 =>
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[511]
private 'role' => string 'ROLE_USER' (length=9)
3 =>
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[506]
private 'role' => string 'IS_AUTHENTICATED_FULLY' (length=22)
4 =>
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[507]
private 'role' => string 'IS_AUTHENTICATED_REMEMBERED' (length=27)
5 =>
object(Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity)[508]
private 'role' => string 'IS_AUTHENTICATED_ANONYMOUSLY' (length=28) |
alors que je m'attend a un false.... J'ai cherché un moment mais je ne comprend pas ce qui se passe... Est'ce que ça peut'être un bug? Merci d'avance