symfony / symfony-docs

The Symfony documentation
https://symfony.com/doc
Other
2.15k stars 5.1k forks source link

[Security] add the $token argument to checkPostAuth() #20066

Open xabbuh opened 1 month ago

xabbuh commented 1 month ago

fixes #20062

Timherlaud commented 1 month ago

Hello,

You can add the import of TokenInterface

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

I think we can add a notice version :

.. versionadded:: 7.2

  The token argument for checkPostAuth function was introduced in Symfony 7.2.

And maybe an example of usage in function :

use Symfony\Component\Security\Core\Exception\AccessDeniedException;

if (!\in_array('foo', $token->getRoleNames())) {
                throw new AccessDeniedException('...');
            }