Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Symfony/Component/Security/Http/Firewall/ResourceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ class ResourceListener implements ListenerInterface
protected $validator;
protected $logger;
protected $tokenTypeHandlerFactory;
protected $accessTokenRoles;

public function __construct(
$providerKey,
TokenStorageInterface $tokenStorage,
AuthenticationManagerInterface $authenticationManager,
ValidatorInterface $validator,
LoggerInterface $logger,
TokenTypeHandlerFactoryInterface $tokenTypeHandlerFactory
TokenTypeHandlerFactoryInterface $tokenTypeHandlerFactory,
array $accessTokenRoles = []
) {
$this->providerKey = $providerKey;
$this->tokenStorage = $tokenStorage;
$this->authenticationManager = $authenticationManager;
$this->validator = $validator;
$this->logger = $logger;
$this->tokenTypeHandlerFactory = $tokenTypeHandlerFactory;
$this->accessTokenRoles = $accessTokenRoles;
}

public function handle(GetResponseEvent $event)
Expand Down Expand Up @@ -100,7 +103,13 @@ public function handle(GetResponseEvent $event)

$token = new AccessToken(
$this->providerKey,
$accessToken
$accessToken,
'',
'',
'',
'',
[],
$this->accessTokenRoles
);
$tokenAuthenticated = $this->authenticationManager->authenticate($token);
$this->tokenStorage->setToken($tokenAuthenticated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ class TokenListener implements ListenerInterface
protected $authenticationManager;
protected $validator;
protected $logger;
protected $clientTokenRoles;

public function __construct(
$providerKey,
TokenStorageInterface $tokenStorage,
AuthenticationManagerInterface $authenticationManager,
ValidatorInterface $validator,
LoggerInterface $logger
LoggerInterface $logger,
array $clientTokenRoles = []
) {
$this->providerKey = $providerKey;
$this->tokenStorage = $tokenStorage;
$this->authenticationManager = $authenticationManager;
$this->validator = $validator;
$this->logger = $logger;
$this->clientTokenRoles = $clientTokenRoles;
}

public function handle(GetResponseEvent $event)
Expand Down Expand Up @@ -110,7 +113,9 @@ public function handle(GetResponseEvent $event)
$token = new ClientCredentialsToken(
$this->providerKey,
$clientId,
$clientSecret
$clientSecret,
'',
$this->clientTokenRoles
);
$tokenAuthenticated = $this->authenticationManager->authenticate($token);
$this->tokenStorage->setToken($tokenAuthenticated);
Expand Down