Skip to content

Impossible to use the security property in ApiProperty attribute #5054

@Xusifob

Description

@Xusifob

API Platform version(s) affected: 3.0.0

Description
When using the security property on the ApiProperty attribute on an entity property, the object object received, is null

How to reproduce

// src/Entity/Dummy.php 

    #[ApiProperty(
        security: "is_granted('VIEW',object)",
        securityPostDenormalize: "is_granted('MODERATE',object)",
        schema: [
            'type' => 'boolean',
        ])]
    public bool $isModerated = false;

In my scenario, VIEW should returns true and MODERATE should returns false

Possible Solution
The security attribute should get an access to the object that is created

Additional Context

Here is the data my voters are getting
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions