for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2018 Spomky-Labs
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OAuth2Framework\SecurityBundle\Resolver;
use OAuth2Framework\SecurityBundle\Security\Authentication\Token\OAuth2Token;
use OAuth2Framework\Component\Core\AccessToken\AccessToken;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
final class AccessTokenResolver implements ArgumentValueResolverInterface
{
/**
* @var TokenStorageInterface
private $tokenStorage;
* AccessTokenResolver constructor.
* @param TokenStorageInterface $tokenStorage
public function __construct(TokenStorageInterface $tokenStorage)
$this->tokenStorage = $tokenStorage;
}
* {@inheritdoc}
public function supports(Request $request, ArgumentMetadata $argument)
if (AccessToken::class !== $argument->getType()) {
return false;
return $this->tokenStorage->getToken() instanceof OAuth2Token;
public function resolve(Request $request, ArgumentMetadata $argument)
$token = $this->tokenStorage->getToken();
if ($token instanceof OAuth2Token) {
yield $token->getAccessToken();