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
9 changes: 9 additions & 0 deletions src/Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace League\Bundle\OAuth2ServerBundle\Controller;

use League\Bundle\OAuth2ServerBundle\Converter\ScopeConverterInterface;
use League\Bundle\OAuth2ServerBundle\Converter\UserConverterInterface;
use League\Bundle\OAuth2ServerBundle\Event\AuthorizationRequestResolveEventFactory;
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
Expand Down Expand Up @@ -40,6 +41,11 @@ final class AuthorizationController
*/
private $userConverter;

/**
* @var ScopeConverterInterface
*/
private $scopeConverter;

/**
* @var ClientManagerInterface
*/
Expand All @@ -65,6 +71,7 @@ public function __construct(
EventDispatcherInterface $eventDispatcher,
AuthorizationRequestResolveEventFactory $eventFactory,
UserConverterInterface $userConverter,
ScopeConverterInterface $scopeConverter,
ClientManagerInterface $clientManager,
HttpMessageFactoryInterface $httpMessageFactory,
HttpFoundationFactoryInterface $httpFoundationFactory,
Expand All @@ -74,6 +81,7 @@ public function __construct(
$this->eventDispatcher = $eventDispatcher;
$this->eventFactory = $eventFactory;
$this->userConverter = $userConverter;
$this->scopeConverter = $scopeConverter;
$this->clientManager = $clientManager;
$this->httpMessageFactory = $httpMessageFactory;
$this->httpFoundationFactory = $httpFoundationFactory;
Expand Down Expand Up @@ -102,6 +110,7 @@ public function indexAction(Request $request): Response
);

$authRequest->setUser($this->userConverter->toLeague($event->getUser()));
$authRequest->setScopes($this->scopeConverter->toLeagueArray($event->getScopes()));

if ($response = $event->getResponse()) {
return $response;
Expand Down
10 changes: 10 additions & 0 deletions src/Event/AuthorizationRequestResolveEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public function getScopes(): array
return $this->scopes;
}

/**
* @param Scope[] $scopes
*/
public function setScopes(array $scopes): self
{
$this->scopes = $scopes;

return $this;
}

public function isAuthorizationApproved(): bool
{
return $this->authorizationRequest->isAuthorizationApproved();
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
service(EventDispatcherInterface::class),
service(AuthorizationRequestResolveEventFactory::class),
service(UserConverterInterface::class),
service(ScopeConverterInterface::class),
service(ClientManagerInterface::class),
service('league.oauth2_server.factory.psr_http'),
service('league.oauth2_server.factory.http_foundation'),
Expand Down