vendor/symfony/security-core/Authentication/AuthenticationTrustResolver.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Security\Core\Authentication;
  11. use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
  12. use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
  13. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  14. /**
  15.  * The default implementation of the authentication trust resolver.
  16.  *
  17.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  18.  */
  19. class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface
  20. {
  21.     public function isAuthenticated(TokenInterface $token null): bool
  22.     {
  23.         return $token && $token->getUser()
  24.             // @deprecated since Symfony 5.4, TokenInterface::isAuthenticated() and AnonymousToken no longer exists in 6.0
  25.             && !$token instanceof AnonymousToken && (!method_exists($token'isAuthenticated') || $token->isAuthenticated(false));
  26.     }
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     public function isAnonymous(TokenInterface $token null/*, $deprecation = true*/)
  31.     {
  32.         if (=== \func_num_args() || false !== func_get_arg(1)) {
  33.             trigger_deprecation('symfony/security-core''5.4''The "%s()" method is deprecated, use "isAuthenticated()" or "isFullFledged()" if you want to check if the request is (fully) authenticated.'__METHOD__);
  34.         }
  35.         return $token instanceof AnonymousToken || ($token && !$token->getUser());
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function isRememberMe(TokenInterface $token null)
  41.     {
  42.         return $token && $token instanceof RememberMeToken;
  43.     }
  44.     /**
  45.      * {@inheritdoc}
  46.      */
  47.     public function isFullFledged(TokenInterface $token null)
  48.     {
  49.         return $token && !$this->isAnonymous($tokenfalse) && !$this->isRememberMe($token);
  50.     }
  51. }