<?php
namespace Can\RestBundle\EventListener;
use Can\RestBundle\Event\GenerateRateLimitKeyEvent;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
/**
* @group ratelimit
*
* @package can/rest-bundle
* @author lechecacharro <lechecacharro@gmail.com>
*/
class RateLimitAuthenticationListener
{
/**
* @var TokenStorageInterface
*/
protected $tokenStorage;
/**
* RateLimitAuthenticationListener constructor.
*
* @param TokenStorageInterface | null $tokenStorage
*/
public function __construct(TokenStorageInterface $tokenStorage = null)
{
$this->tokenStorage = $tokenStorage;
}
/**
* @param GenerateRateLimitKeyEvent $event
*/
public function onGenerateKey(GenerateRateLimitKeyEvent $event): void
{
$token = null;//$this->tokenStorage->getToken();
if (null === $token) {
return;
}
$event->addToKey($token);
}
}