Skip to content

[SecurityBundle] Fatal error on check is granted for class field #9

@ishakuta

Description

@ishakuta

Initial issue described here symfony/symfony#12875 by @alipek

Here's updated description:

Try to check field: is_granted('VIEW', nameClass, 'fooFieldName')
application throw error:

Fatal Error: Argument 1 passed to Symfony\Component\Security\Acl\Domain\UserSecurityIdentity::equals() must implement interface Symfony\Component\Security\Acl\Model\SecurityIdentityInterface, instance of Symfony\Component\Security\Acl\Domain\FieldEntry given

or, if sid is Role:

Catchable Fatal Error: Argument 1 passed to Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity::equals() must implement interface Symfony\Component\Security\Acl\Model\SecurityIdentityInterface,
instance of Symfony\Component\Security\Acl\Domain\FieldEntry given,
called in ... custom class ("$sid->equals($ace->getSecurityIdentity());") ... and defined in vendor/symfony/symfony/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php on line 53

This is problem with serializaton of FieldEntry and Entry types.
serialization working when Acl have only one object of FieldEntry, but when is more that failed

@alipek showed this with test in pull request symfony/symfony#12873, that was closed by @fabpot due to acl component was moved into this repository,
so here's new PR with test to demonstrate bug: #8

Update: Here's serialized data from the example test (difference between two ACEs highlighted):

a:1:{i:0;a:2:{s:8:"fieldOne";a:1:{i:0;C:48:"Symfony\Component\Security\Acl\Domain\FieldEntry":312:{a:2:{i:0;s:3:"foo";i:1;s:279:"a:7:{i:0;i:123456;i:1;i:123;i:2;**O:39:"Mock_SecurityIdentityInterface_54ceb335":2:{s:67:"Mock_SecurityIdentityInterface_54ceb335__phpunit_invocationMocker";N;s:65:"Mock_SecurityIdentityInterface_54ceb335__phpunit_originalObject";N;}**i:3;s:8:"foostrat";i:4;b:0;i:5;b:1;i:6;b:1;}";}}}s:8:"fieldTwo";a:1:{i:0;C:48:"Symfony\Component\Security\Acl\Domain\FieldEntry":112:{a:2:{i:0;s:3:"foo";i:1;s:80:"a:7:{i:0;i:123456;i:1;i:123;i:2;**r:8;**i:3;s:8:"foostrat";i:4;b:0;i:5;b:1;i:6;b:1;}";}}}}}

First FieldEntry has SecurityIdentityInterface mock,
second FieldEntry has "r8", that is somehow restored to first FieldEntry.

PHP 5.5.26
Not exactly the same, but similar serialize/unserialize issue: https://3v4l.org/sSL6F
Another example provided by @alsma https://3v4l.org/viORV

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions