-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #196 Require a logged in user to resolve an authorization req…
…uest (ajgarlag) This PR was squashed before being merged into the 0.9-dev branch. Discussion ---------- Require a logged in user to resolve an authorization request Introduces BC breaks Fix #195 Commits ------- aeaa2d3 Require a logged in user to resolve an authorization request
- Loading branch information
Showing
12 changed files
with
122 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Event/AuthorizationRequestResolveEventFactoryTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\Bundle\OAuth2ServerBundle\Event; | ||
|
||
use League\Bundle\OAuth2ServerBundle\Converter\ScopeConverterInterface; | ||
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface; | ||
use League\OAuth2\Server\RequestTypes\AuthorizationRequestInterface; | ||
use Symfony\Bundle\SecurityBundle\Security; | ||
use Symfony\Component\Security\Core\Security as LegacySecurity; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait AuthorizationRequestResolveEventFactoryTrait | ||
{ | ||
/** | ||
* @var ScopeConverterInterface | ||
*/ | ||
private $scopeConverter; | ||
|
||
/** | ||
* @var ClientManagerInterface | ||
*/ | ||
private $clientManager; | ||
|
||
/** | ||
* @var Security|LegacySecurity | ||
*/ | ||
private $security; | ||
|
||
public function fromAuthorizationRequest(AuthorizationRequestInterface $authorizationRequest): AuthorizationRequestResolveEvent | ||
{ | ||
$scopes = $this->scopeConverter->toDomainArray(array_values($authorizationRequest->getScopes())); | ||
|
||
$client = $this->clientManager->find($authorizationRequest->getClient()->getIdentifier()); | ||
|
||
if (null === $client) { | ||
throw new \RuntimeException(\sprintf('No client found for the given identifier \'%s\'.', $authorizationRequest->getClient()->getIdentifier())); | ||
} | ||
|
||
$user = $this->security->getUser(); | ||
if (null === $user) { | ||
throw new \RuntimeException('A logged in user is required to resolve the authorization request.'); | ||
} | ||
|
||
return new AuthorizationRequestResolveEvent($authorizationRequest, $scopes, $client, $user); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
src/EventListener/AuthorizationRequestUserResolvingListener.php
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/EventListener/AuthorizationRequestUserResolvingListenerTrait.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.