Skip to content

Commit

Permalink
Merge pull request #25 from gepo/symfony30
Browse files Browse the repository at this point in the history
Add quotation for service injection for compatiblity with Symfony 3.0
  • Loading branch information
cryptiklemur committed Jan 14, 2016
2 parents e0b8c8a + e49e632 commit ba7e3fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Uecode/Bundle/ApiKeyBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ parameters:
services:
uecode.api_key.provider.user_provider:
class: %uecode.api_key.provider.user_provider.class%
arguments: [@fos_user.user_manager]
arguments: ["@fos_user.user_manager"]
uecode.api_key.provider.api_key:
class: %uecode.api_key.provider.api_key.class%
arguments: [""]
uecode.api_key.listener.api_key:
class: %uecode.api_key.listener.api_key.class%
arguments: [@security.context, @security.authentication.manager, @uecode.api_key.extractor]
arguments: ["@security.token_storage", "@security.authentication.manager", "@uecode.api_key.extractor"]

uecode.api_key.extractor.query:
class: %uecode.api_key.extractor.query.class%
Expand Down
20 changes: 10 additions & 10 deletions src/Uecode/Bundle/ApiKeyBundle/Security/Firewall/ApiKeyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Token\ApiKeyUserToken;
use Uecode\Bundle\ApiKeyBundle\Extractor\KeyExtractor;
Expand All @@ -17,23 +17,23 @@
class ApiKeyListener implements ListenerInterface
{
/**
* @var SecurityContextInterface
* @var TokenStorageInterface
*/
protected $securityContext;
private $tokenStorage;

/**
* @var AuthenticationManagerInterface
*/
protected $authenticationManager;
private $authenticationManager;

/**
* @var KeyExtractor
*/
protected $keyExtractor;
private $keyExtractor;

public function __construct(SecurityContextInterface $context, AuthenticationManagerInterface $manager, KeyExtractor $keyExtractor)
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $manager, KeyExtractor $keyExtractor)
{
$this->securityContext = $context;
$this->tokenStorage = $tokenStorage;
$this->authenticationManager = $manager;
$this->keyExtractor = $keyExtractor;
}
Expand Down Expand Up @@ -61,13 +61,13 @@ public function handle(GetResponseEvent $event)

try {
$authToken = $this->authenticationManager->authenticate($token);
$this->securityContext->setToken($authToken);
$this->tokenStorage->setToken($authToken);

return;
} catch (AuthenticationException $failed) {
$token = $this->securityContext->getToken();
$token = $this->tokenStorage->getToken();
if ($token instanceof ApiKeyUserToken && $token->getCredentials() == $apiKey) {
$this->securityContext->setToken(null);
$this->tokenStorage->setToken(null);
}

$message = $failed->getMessage();
Expand Down

0 comments on commit ba7e3fa

Please sign in to comment.