Skip to content

Commit

Permalink
Merge pull request EC-CUBE#22 from nanasess/require-redirect_uri
Browse files Browse the repository at this point in the history
redirect_uri を必須にする
  • Loading branch information
okazy authored Jul 14, 2020
2 parents f155e40 + b8084ef commit 00c8b98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions EventListener/AuthorizationRequestResolveListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Eccube\Entity\Master\Authority;
use Eccube\Entity\Member;
use League\OAuth2\Server\Exception\OAuthServerException;
use Plugin\Api\Form\Type\Admin\OAuth2AuthorizationType;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -60,6 +61,12 @@ public function onAuthorizationRequestResolve(AuthorizationRequestResolveEvent $
return;
}

if (!$request->query->has('redirect_uri')) {
// redirect_uri_mismatch を返すべきだが OAuthServerException ではサポートされていない
// http://openid-foundation-japan.github.io/draft-ietf-oauth-v2.ja.html#auth-error-codes
throw OAuthServerException::invalidRequest('redirect_uri');
}

if (!$event->isAuthorizationApproved()) {
$builder = $this->formFactory->createBuilder(OAuth2AuthorizationType::class);
$form = $builder->getForm();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Web/Admin/OAuth2/OAuth2ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testRoutingAdminOauth2Authorize_ログインしている場合
'oauth2_authorize',
[
'client_id' => $Client->getIdentifier(),
'redirect_uri' => current($Client->getRedirectUris()),
'redirect_uri' => (string) current($Client->getRedirectUris()),
'response_type' => 'code',
'scope' => 'read',
'state' => 'xxx'
Expand All @@ -57,7 +57,7 @@ public function testRoutingAdminOauth2Authorize_権限移譲を許可()
'oauth2_authorize',
[
'client_id' => $Client->getIdentifier(),
'redirect_uri' => current($Client->getRedirectUris()),
'redirect_uri' => (string) current($Client->getRedirectUris()),
'response_type' => 'code',
'scope' => 'read',
'state' => 'xxx'
Expand Down

0 comments on commit 00c8b98

Please sign in to comment.