api-platform-security
Installation
SKILL.md
Api Platform Security (Symfony)
Use when
- Restricting who may call each operation of an API Platform resource.
- Authorization depends on the object (owner) or on the submitted data.
- Users must see only a subset of a collection.
- Fields must be hidden depending on role or ownership.
Default workflow
- Set
securityper operation withis_granted(),object, anduser, plus asecurityMessage. - Move complex rules into voters:
is_granted('POST_EDIT', object). - When the rule depends on input, use
securityPostDenormalize, orsecurityPostValidationto run after the Validator. - Scope rows with a
QueryCollectionExtensionInterface(andQueryItemExtensionInterface) or a state provider. - Hide fields with serializer groups and a decorated context builder, and guard the firewall with
access_control. - Test both the grant and the deny case for every protected operation.