Description
The security system is powerful, and allows defining complex expressions close to where the operation is defined. The $resourceAccessCheckerContext on \ApiPlatform\Symfony\Security\State\resourceAccessCheckerContext:76 only gets the previous_object, object, and request to work with and Symfony security added user already.
You'd expect the uriVariables to be available in there, and when possible for them to be resolved as items already. This allows leveraging the operation's capabilities to resolve items even further with regards to security.
Example
#[ApiResource(
operations: [
new Post(
uriTemplate: '/me/foo/{foo}/bar',
uriVariables: [
'foo' => new Link(
toClass: Foo::class,
),
],
security: "is_granted('ROLE_USER') and user.bar === foo.bar",
),
)
]
The above right now will lead to a SyntaxError exception:
Variable "foo" is not valid around position 42 for expression `is_granted('ROLE_USER') and user.bar === foo.bar`.