private readonly AccessTokenHandlerInterface
$accessTokenHandler,
private readonly AccessTokenExtractorInterface
$accessTokenExtractor,
private readonly ?UserProviderInterface
$userProvider = null,
private readonly ?AuthenticationSuccessHandlerInterface
$successHandler = null,
private readonly ?AuthenticationFailureHandlerInterface
$failureHandler = null,
private readonly ?string
$realm = null,
) { } public function supports(Request
$request): ?bool
{ return null ===
$this->accessTokenExtractor->
extractAccessToken($request) ? false : null;
} public function authenticate(Request
$request): Passport
{ $accessToken =
$this->accessTokenExtractor->
extractAccessToken($request);
if (!
$accessToken) { throw new BadCredentialsException('Invalid credentials.'
);
} $userBadge =
$this->accessTokenHandler->
getUserBadgeFrom($accessToken);
if ($this->userProvider
&& (null ===
$userBadge->
getUserLoader() ||
$userBadge->
getUserLoader() instanceof FallbackUserLoader
)) {