From 63b3941025df51575bc30f87885f0a04678a9b5c Mon Sep 17 00:00:00 2001 From: Pavel Dyakonov Date: Mon, 9 Sep 2019 11:56:19 +0300 Subject: [PATCH] add ChainUserProvider --- Security/Guard/JWTTokenAuthenticator.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Security/Guard/JWTTokenAuthenticator.php b/Security/Guard/JWTTokenAuthenticator.php index dd6895a5..3862b41d 100644 --- a/Security/Guard/JWTTokenAuthenticator.php +++ b/Security/Guard/JWTTokenAuthenticator.php @@ -27,6 +27,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; +use Symfony\Component\Security\Core\User\ChainUserProvider; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; @@ -285,6 +286,14 @@ protected function loadUser(UserProviderInterface $userProvider, array $payload, return $userProvider->loadUserByUsernameAndPayload($identity, $payload); } + if ($userProvider instanceof ChainUserProvider) { + foreach ($userProvider->getProviders() as $provider) { + if ($provider instanceof PayloadAwareUserProviderInterface) { + return $provider->loadUserByUsernameAndPayload($identity, $payload); + } + } + } + return $userProvider->loadUserByUsername($identity); } }