diff --git a/ApiNav.php b/ApiNav.php index 7302a01..2ba3451 100644 --- a/ApiNav.php +++ b/ApiNav.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api; +namespace Plugin\Api42; use Eccube\Common\EccubeNav; diff --git a/Bundle/ApiBundle.php b/Bundle/ApiBundle.php index 0b8535f..76e0657 100644 --- a/Bundle/ApiBundle.php +++ b/Bundle/ApiBundle.php @@ -11,10 +11,10 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Bundle; +namespace Plugin\Api42\Bundle; -use Plugin\Api\DependencyInjection\ApiExtension; -use Plugin\Api\DependencyInjection\Compiler\ApiCompilerPass; +use Plugin\Api42\DependencyInjection\ApiExtension; +use Plugin\Api42\DependencyInjection\Compiler\ApiCompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; diff --git a/Command/DumpSchemaCommand.php b/Command/DumpSchemaCommand.php index 2cef295..df81e9e 100644 --- a/Command/DumpSchemaCommand.php +++ b/Command/DumpSchemaCommand.php @@ -11,10 +11,10 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Command; +namespace Plugin\Api42\Command; use GraphQL\Utils\SchemaPrinter; -use Plugin\Api\GraphQL\Schema; +use Plugin\Api42\GraphQL\Schema; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/Controller/Admin/GraphiQLController.php b/Controller/Admin/GraphiQLController.php index 8b93bbb..00fe42e 100644 --- a/Controller/Admin/GraphiQLController.php +++ b/Controller/Admin/GraphiQLController.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Controller\Admin; +namespace Plugin\Api42\Controller\Admin; use Eccube\Controller\AbstractController; use GraphQL\Error\DebugFlag; use GraphQL\GraphQL; -use Plugin\Api\GraphQL\Schema; +use Plugin\Api42\GraphQL\Schema; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -46,7 +46,7 @@ public function __construct( /** * @Route("/%eccube_admin_route%/graphiql", name="admin_api_graphiql", methods={"GET"}) - * @Template("@Api/admin/OAuth/graphiql.twig") + * @Template("@Api42/admin/OAuth/graphiql.twig") * * @return array */ diff --git a/Controller/Admin/OAuthController.php b/Controller/Admin/OAuthController.php index 9f70ae7..ab49663 100644 --- a/Controller/Admin/OAuthController.php +++ b/Controller/Admin/OAuthController.php @@ -11,26 +11,26 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Controller\Admin; +namespace Plugin\Api42\Controller\Admin; use Eccube\Controller\AbstractController; use Exception; -use Plugin\Api\Form\Type\Admin\ClientType; +use Plugin\Api42\Form\Type\Admin\ClientType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; -use Trikoder\Bundle\OAuth2Bundle\Manager\AccessTokenManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Manager\ClientFilter; -use Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Manager\RefreshTokenManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCode; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; -use Trikoder\Bundle\OAuth2Bundle\Model\Grant; -use Trikoder\Bundle\OAuth2Bundle\Model\RedirectUri; -use Trikoder\Bundle\OAuth2Bundle\Model\Scope; -use Trikoder\Bundle\OAuth2Bundle\OAuth2Grants; +use League\Bundle\OAuth2ServerBundle\Manager\AccessTokenManagerInterface; +use League\Bundle\OAuth2ServerBundle\Manager\ClientFilter; +use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface; +use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface; +use League\Bundle\OAuth2ServerBundle\Model\AuthorizationCode; +use League\Bundle\OAuth2ServerBundle\Model\Client; +use League\Bundle\OAuth2ServerBundle\Model\Grant; +use League\Bundle\OAuth2ServerBundle\Model\RedirectUri; +use League\Bundle\OAuth2ServerBundle\Model\Scope; +use League\Bundle\OAuth2ServerBundle\OAuth2Grants; class OAuthController extends AbstractController { @@ -67,7 +67,7 @@ public function __construct( /** * @Route("/%eccube_admin_route%/api/config", name="admin_api_config", methods={"GET"}) * @Route("/%eccube_admin_route%/api/oauth", name="admin_api_oauth", methods={"GET"}) - * @Template("@Api/admin/OAuth/index.twig") + * @Template("@Api42/admin/OAuth/index.twig") * * @param Request $request * @@ -85,7 +85,7 @@ public function index(Request $request) /** * @Route("/%eccube_admin_route%/api/oauth/new", name="admin_api_oauth_new", methods={"GET", "POST"}) - * @Template("@Api/admin/OAuth/edit.twig") + * @Template("@Api42/admin/OAuth/edit.twig") * * @param Request $request * @@ -95,6 +95,8 @@ public function index(Request $request) */ public function create(Request $request) { + $name = ''; + $builder = $this->formFactory ->createBuilder(ClientType::class); @@ -106,7 +108,7 @@ public function create(Request $request) $secret = $form->get('secret')->getData(); try { - $client = new Client($identifier, $secret); + $client = new Client($name, $identifier, $secret); $client = $this->updateClientFromForm($client, $form); $this->clientManager->save($client); diff --git a/Controller/Admin/WebHookController.php b/Controller/Admin/WebHookController.php index 7282d26..edf7489 100644 --- a/Controller/Admin/WebHookController.php +++ b/Controller/Admin/WebHookController.php @@ -11,13 +11,13 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Controller\Admin; +namespace Plugin\Api42\Controller\Admin; use Eccube\Controller\AbstractController; use Exception; -use Plugin\Api\Entity\WebHook; -use Plugin\Api\Form\Type\Admin\WebHookType; -use Plugin\Api\Repository\WebHookRepository; +use Plugin\Api42\Entity\WebHook; +use Plugin\Api42\Form\Type\Admin\WebHookType; +use Plugin\Api42\Repository\WebHookRepository; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -41,7 +41,7 @@ public function __construct(WebHookRepository $webHookRepository) /** * @Route("/%eccube_admin_route%/api/webhook", name="admin_api_webhook", methods={"GET"}) - * @Template("@Api/admin/WebHook/index.twig") + * @Template("@Api42/admin/WebHook/index.twig") */ public function index() { @@ -55,7 +55,7 @@ public function index() /** * @Route("/%eccube_admin_route%/api/webhook/new", name="admin_api_webhook_new", methods={"GET", "POST"}) * @Route("/%eccube_admin_route%/api/webhook/edit/{id}", requirements={"id" = "\d+"}, name="admin_api_webhook_edit", methods={"GET", "POST"}) - * @Template("@Api/admin/WebHook/edit.twig") + * @Template("@Api42/admin/WebHook/edit.twig") * * @param Request $request * @param WebHook|null $WebHook diff --git a/Controller/ApiController.php b/Controller/ApiController.php index bee6cda..ee9faa9 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -11,20 +11,21 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Controller; +namespace Plugin\Api42\Controller; use Eccube\Controller\AbstractController; use GraphQL\Error\DebugFlag; use GraphQL\GraphQL; use GraphQL\Validator\DocumentValidator; -use Plugin\Api\GraphQL\Schema; -use Plugin\Api\GraphQL\ScopeValidationRule; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Schema; +use Plugin\Api42\GraphQL\ScopeValidationRule; +use Plugin\Api42\GraphQL\Types; use RuntimeException; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Annotation\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; class ApiController extends AbstractController { @@ -62,8 +63,9 @@ public function __construct( /** * @Route("/api", name="api", methods={"GET", "POST"}) - * @Security("has_role('ROLE_OAUTH2_READ') or has_role('ROLE_OAUTH2_WRITE')") + * @IsGranted("ROLE_OAUTH2_READ", "ROLE_OAUTH2_WRITE") */ + public function index(Request $request) { switch ($request->getMethod()) { diff --git a/DependencyInjection/ApiExtension.php b/DependencyInjection/ApiExtension.php index 40f2c5e..8a6c9c9 100644 --- a/DependencyInjection/ApiExtension.php +++ b/DependencyInjection/ApiExtension.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\DependencyInjection; +namespace Plugin\Api42\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; @@ -39,6 +39,13 @@ public function prepend(ContainerBuilder $container) 'oauth2' => true, 'provider' => 'member_provider' ]; + unset($security["firewalls"]["admin"]["form_login"]["csrf_token_generator"]); + unset($security["firewalls"]["admin"]["anonymous"]); + } + + if ($name === 'customer') { + unset($security["firewalls"]["customer"]["form_login"]["csrf_token_generator"]); + unset($security["firewalls"]["customer"]["anonymous"]); } $replaced[$name] = $security["firewalls"][$name]; } diff --git a/DependencyInjection/Compiler/ApiCompilerPass.php b/DependencyInjection/Compiler/ApiCompilerPass.php index 14c1b33..1104807 100644 --- a/DependencyInjection/Compiler/ApiCompilerPass.php +++ b/DependencyInjection/Compiler/ApiCompilerPass.php @@ -11,15 +11,15 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\DependencyInjection\Compiler; +namespace Plugin\Api42\DependencyInjection\Compiler; use League\OAuth2\Server\CryptKey; -use Plugin\Api\GraphQL\AllowList; -use Plugin\Api\GraphQL\Mutation; -use Plugin\Api\GraphQL\Query; -use Plugin\Api\GraphQL\Types; -use Plugin\Api\Service\WebHookEvents; -use Plugin\Api\Service\WebHookTrigger; +use Plugin\Api42\GraphQL\AllowList; +use Plugin\Api42\GraphQL\Mutation; +use Plugin\Api42\GraphQL\Query; +use Plugin\Api42\GraphQL\Types; +use Plugin\Api42\Service\WebHookEvents; +use Plugin\Api42\Service\WebHookTrigger; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -34,9 +34,9 @@ public function process(ContainerBuilder $container) $this->configureSchema($container); $plugins = $container->getParameter('eccube.plugins.enabled'); - if (!in_array('Api', $plugins)) { - if ($container->hasDefinition('Trikoder\Bundle\OAuth2Bundle\EventListener\ConvertExceptionToResponseListener')) { - $def = $container->getDefinition('Trikoder\Bundle\OAuth2Bundle\EventListener\ConvertExceptionToResponseListener'); + if (!in_array('Api42', $plugins)) { + if ($container->hasDefinition('League\Bundle\OAuth2ServerBundle\EventListener\AddClientDefaultScopesListener')) { + $def = $container->getDefinition('League\Bundle\OAuth2ServerBundle\EventListener\AddClientDefaultScopesListener'); $def->clearTags(); } } @@ -80,7 +80,7 @@ private function configureAllowList(ContainerBuilder $container) private function configureKeyPair(ContainerBuilder $container) { $projectDir = $container->getParameter('kernel.project_dir'); - $oauthConfig = $container->getExtensionConfig('trikoder_oauth2'); + $oauthConfig = $container->getExtensionConfig('league_oauth2_server'); $oauthConfig = $container->resolveEnvPlaceholders($oauthConfig, true); $privateKey = str_replace('%%kernel.project_dir%%', $projectDir, $oauthConfig[0]['authorization_server']['private_key']); $publicKey = str_replace('%%kernel.project_dir%%', $projectDir, $oauthConfig[0]['resource_server']['public_key']); diff --git a/Doctrine/EventSubscriber/EntityListener.php b/Doctrine/EventSubscriber/EntityListener.php index c33df0d..e13de44 100644 --- a/Doctrine/EventSubscriber/EntityListener.php +++ b/Doctrine/EventSubscriber/EntityListener.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Doctrine\EventSubscriber; +namespace Plugin\Api42\Doctrine\EventSubscriber; use Doctrine\Common\EventSubscriber; -use Doctrine\Common\Persistence\Event\LifecycleEventArgs; +use Doctrine\Persistence\Event\LifecycleEventArgs; use Doctrine\ORM\Events; -use Plugin\Api\Service\WebHookEvents; +use Plugin\Api42\Service\WebHookEvents; class EntityListener implements EventSubscriber { diff --git a/Entity/WebHook.php b/Entity/WebHook.php index 2ab0439..48beae0 100644 --- a/Entity/WebHook.php +++ b/Entity/WebHook.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Entity; +namespace Plugin\Api42\Entity; use DateTime; use Doctrine\ORM\Mapping as ORM; @@ -23,7 +23,7 @@ * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255) * @ORM\HasLifecycleCallbacks() - * @ORM\Entity(repositoryClass="Plugin\Api\Repository\WebHookRepository") + * @ORM\Entity(repositoryClass="Plugin\Api42\Repository\WebHookRepository") */ class WebHook { diff --git a/EventListener/AuthorizationRequestResolveListener.php b/EventListener/AuthorizationRequestResolveListener.php index 5cf6ac7..93b9bdb 100644 --- a/EventListener/AuthorizationRequestResolveListener.php +++ b/EventListener/AuthorizationRequestResolveListener.php @@ -11,19 +11,18 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\EventListener; +namespace Plugin\Api42\EventListener; 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 Plugin\Api42\Form\Type\Admin\OAuth2AuthorizationType; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; -use Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEvent; -use Trikoder\Bundle\OAuth2Bundle\OAuth2Events; +use League\Bundle\OAuth2ServerBundle\Event\AuthorizationRequestResolveEvent; +use League\Bundle\OAuth2ServerBundle\OAuth2Events; use Twig\Environment as Twig; final class AuthorizationRequestResolveListener implements EventSubscriberInterface @@ -31,9 +30,6 @@ final class AuthorizationRequestResolveListener implements EventSubscriberInterf /** @var Twig */ protected $twig; - /** @var PsrHttpFactory */ - protected $psr7Factory; - /** @var FormFactoryInterface */ protected $formFactory; @@ -42,12 +38,10 @@ final class AuthorizationRequestResolveListener implements EventSubscriberInterf public function __construct( Twig $twig, - PsrHttpFactory $psr7Factory, FormFactoryInterface $formFactory, RequestStack $requestStack ) { $this->twig = $twig; - $this->psr7Factory = $psr7Factory; $this->formFactory = $formFactory; $this->requestStack = $requestStack; } @@ -87,7 +81,7 @@ public function onAuthorizationRequestResolve(AuthorizationRequestResolveEvent $ $form['state']->setData($event->getState()); $form['scope']->setData(join(' ', $event->getScopes())); $content = $this->twig->render( - '@Api/admin/OAuth/authorization.twig', + '@Api42/admin/OAuth/authorization.twig', [ 'scopes' => $event->getScopes(), 'form' => $form->createView(), @@ -104,8 +98,7 @@ public function onAuthorizationRequestResolve(AuthorizationRequestResolveEvent $ $event->resolveAuthorization(AuthorizationRequestResolveEvent::AUTHORIZATION_DENIED); } } else { - $Response = $this->psr7Factory->createResponse(Response::create($content)); - $event->setResponse($Response); + $event->setResponse(Response::create($content)); } } } diff --git a/EventListener/UserResolveListener.php b/EventListener/UserResolveListener.php index a374192..58a446b 100644 --- a/EventListener/UserResolveListener.php +++ b/EventListener/UserResolveListener.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\EventListener; +namespace Plugin\Api42\EventListener; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; -use Trikoder\Bundle\OAuth2Bundle\Event\UserResolveEvent; +use League\Bundle\OAuth2ServerBundle\Event\UserResolveEvent; final class UserResolveListener { diff --git a/Form/Type/Admin/ClientType.php b/Form/Type/Admin/ClientType.php index 313896f..596d50a 100644 --- a/Form/Type/Admin/ClientType.php +++ b/Form/Type/Admin/ClientType.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Form\Type\Admin; +namespace Plugin\Api42\Form\Type\Admin; use Eccube\Common\EccubeConfig; use Exception; @@ -20,7 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints as Assert; -use Trikoder\Bundle\OAuth2Bundle\OAuth2Grants; +use League\Bundle\OAuth2ServerBundle\OAuth2Grants; class ClientType extends AbstractType { diff --git a/Form/Type/Admin/OAuth2AuthorizationType.php b/Form/Type/Admin/OAuth2AuthorizationType.php index 5d62f99..081aafc 100644 --- a/Form/Type/Admin/OAuth2AuthorizationType.php +++ b/Form/Type/Admin/OAuth2AuthorizationType.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Form\Type\Admin; +namespace Plugin\Api42\Form\Type\Admin; use Eccube\Common\EccubeConfig; use Symfony\Component\Form\AbstractType; diff --git a/Form/Type/Admin/WebHookType.php b/Form/Type/Admin/WebHookType.php index b37b68e..bc657fe 100644 --- a/Form/Type/Admin/WebHookType.php +++ b/Form/Type/Admin/WebHookType.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Form\Type\Admin; +namespace Plugin\Api42\Form\Type\Admin; use Eccube\Form\Type\ToggleSwitchType; use Symfony\Component\Form\AbstractType; diff --git a/GraphQL/AllowList.php b/GraphQL/AllowList.php index 4ea30c7..b23c589 100644 --- a/GraphQL/AllowList.php +++ b/GraphQL/AllowList.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; class AllowList { diff --git a/GraphQL/Error/InvalidArgumentException.php b/GraphQL/Error/InvalidArgumentException.php index b20e0a1..d8bd00c 100644 --- a/GraphQL/Error/InvalidArgumentException.php +++ b/GraphQL/Error/InvalidArgumentException.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Error; +namespace Plugin\Api42\GraphQL\Error; use GraphQL\Error\ClientAware; diff --git a/GraphQL/Mutation.php b/GraphQL/Mutation.php index eab18d0..a25866e 100644 --- a/GraphQL/Mutation.php +++ b/GraphQL/Mutation.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; interface Mutation { diff --git a/GraphQL/Mutation/UpdateProductStockMutation.php b/GraphQL/Mutation/UpdateProductStockMutation.php index bafe0fa..12dd9a7 100644 --- a/GraphQL/Mutation/UpdateProductStockMutation.php +++ b/GraphQL/Mutation/UpdateProductStockMutation.php @@ -11,15 +11,15 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Mutation; +namespace Plugin\Api42\GraphQL\Mutation; use Doctrine\ORM\EntityManagerInterface; use Eccube\Entity\ProductClass; use Eccube\Repository\ProductClassRepository; use GraphQL\Type\Definition\Type; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; -use Plugin\Api\GraphQL\Mutation; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Mutation; +use Plugin\Api42\GraphQL\Types; class UpdateProductStockMutation implements Mutation { diff --git a/GraphQL/Mutation/UpdateShippedMutation.php b/GraphQL/Mutation/UpdateShippedMutation.php index f83fc87..1d6f6ac 100644 --- a/GraphQL/Mutation/UpdateShippedMutation.php +++ b/GraphQL/Mutation/UpdateShippedMutation.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Mutation; +namespace Plugin\Api42\GraphQL\Mutation; use Doctrine\ORM\EntityManagerInterface; use Eccube\Common\EccubeConfig; @@ -23,10 +23,10 @@ use Eccube\Service\MailService; use Eccube\Service\OrderStateMachine; use GraphQL\Type\Definition\Type; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; -use Plugin\Api\GraphQL\Mutation; -use Plugin\Api\GraphQL\Type\Definition\DateTimeType; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Mutation; +use Plugin\Api42\GraphQL\Type\Definition\DateTimeType; +use Plugin\Api42\GraphQL\Types; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\ConstraintViolationInterface; diff --git a/GraphQL/Query.php b/GraphQL/Query.php index e55b7a5..0853788 100644 --- a/GraphQL/Query.php +++ b/GraphQL/Query.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; interface Query { diff --git a/GraphQL/Query/CustomerQuery.php b/GraphQL/Query/CustomerQuery.php index 18fe50a..23c59df 100644 --- a/GraphQL/Query/CustomerQuery.php +++ b/GraphQL/Query/CustomerQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Customer; diff --git a/GraphQL/Query/CustomersQuery.php b/GraphQL/Query/CustomersQuery.php index 47b5348..5a01910 100644 --- a/GraphQL/Query/CustomersQuery.php +++ b/GraphQL/Query/CustomersQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Customer; use Eccube\Form\Type\Admin\SearchCustomerType; diff --git a/GraphQL/Query/OrderQuery.php b/GraphQL/Query/OrderQuery.php index d451547..aa592fa 100644 --- a/GraphQL/Query/OrderQuery.php +++ b/GraphQL/Query/OrderQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Order; diff --git a/GraphQL/Query/OrdersQuery.php b/GraphQL/Query/OrdersQuery.php index c68e9d9..1e6d3cf 100644 --- a/GraphQL/Query/OrdersQuery.php +++ b/GraphQL/Query/OrdersQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Order; use Eccube\Form\Type\Admin\SearchOrderType; diff --git a/GraphQL/Query/ProductQuery.php b/GraphQL/Query/ProductQuery.php index aaafe12..8db9024 100644 --- a/GraphQL/Query/ProductQuery.php +++ b/GraphQL/Query/ProductQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Product; diff --git a/GraphQL/Query/ProductsQuery.php b/GraphQL/Query/ProductsQuery.php index 4dfdb39..85b997a 100644 --- a/GraphQL/Query/ProductsQuery.php +++ b/GraphQL/Query/ProductsQuery.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Entity\Product; use Eccube\Form\Type\Admin\SearchProductType; diff --git a/GraphQL/Query/SearchFormQuery.php b/GraphQL/Query/SearchFormQuery.php index f13090e..2c5453d 100644 --- a/GraphQL/Query/SearchFormQuery.php +++ b/GraphQL/Query/SearchFormQuery.php @@ -11,16 +11,16 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Eccube\Common\EccubeConfig; use Eccube\Util\StringUtil; use GraphQL\Type\Definition\Type; use Knp\Component\Pager\PaginatorInterface; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; -use Plugin\Api\GraphQL\Query; -use Plugin\Api\GraphQL\Type\ConnectionType; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Query; +use Plugin\Api42\GraphQL\Type\ConnectionType; +use Plugin\Api42\GraphQL\Types; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\FormBuilderInterface; @@ -97,7 +97,7 @@ protected function createQuery($entityClass, $searchFormType, $resolver) $type = Type::int(); break; case DateTimeType::class: - $type = \Plugin\Api\GraphQL\Type\Definition\DateTimeType::dateTime(); + $type = \Plugin\Api42\GraphQL\Type\Definition\DateTimeType::dateTime(); break; default: $type = Type::string(); @@ -166,6 +166,7 @@ private function overrideDateTimeFormat(FormBuilderInterface $builder) if ($type instanceof DateTimeType) { $options = $field->getOptions(); $options['format'] = "yyyy-MM-dd'T'HH:mm:ssZ"; + $options['html5'] = false; $builder->add($field->getName(), get_class($type), $options); } } diff --git a/GraphQL/Query/SingleResultQuery.php b/GraphQL/Query/SingleResultQuery.php index 1510464..30970e2 100644 --- a/GraphQL/Query/SingleResultQuery.php +++ b/GraphQL/Query/SingleResultQuery.php @@ -11,13 +11,13 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Query; +namespace Plugin\Api42\GraphQL\Query; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use GraphQL\Type\Definition\Type; -use Plugin\Api\GraphQL\Query; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Query; +use Plugin\Api42\GraphQL\Types; abstract class SingleResultQuery implements Query { diff --git a/GraphQL/Schema.php b/GraphQL/Schema.php index 760bd8b..a30bc46 100644 --- a/GraphQL/Schema.php +++ b/GraphQL/Schema.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; use ArrayObject; use GraphQL\Type\Definition\ObjectType; diff --git a/GraphQL/ScopeValidationRule.php b/GraphQL/ScopeValidationRule.php index d2f0f07..db80b17 100644 --- a/GraphQL/ScopeValidationRule.php +++ b/GraphQL/ScopeValidationRule.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; use GraphQL\Error\Error; use GraphQL\Language\AST\NodeKind; diff --git a/GraphQL/Type/ConnectionType.php b/GraphQL/Type/ConnectionType.php index 712f8ad..4ec2305 100644 --- a/GraphQL/Type/ConnectionType.php +++ b/GraphQL/Type/ConnectionType.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Type; +namespace Plugin\Api42\GraphQL\Type; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; use Knp\Component\Pager\Pagination\PaginationInterface; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Types; class ConnectionType extends ObjectType { diff --git a/GraphQL/Type/Definition/DateTimeType.php b/GraphQL/Type/Definition/DateTimeType.php index cf1b689..965145a 100644 --- a/GraphQL/Type/Definition/DateTimeType.php +++ b/GraphQL/Type/Definition/DateTimeType.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Type\Definition; +namespace Plugin\Api42\GraphQL\Type\Definition; use DateTime; use DateTimeInterface; @@ -20,7 +20,7 @@ use GraphQL\Language\AST\StringValueNode; use GraphQL\Type\Definition\ScalarType; use GraphQL\Utils\Utils; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; class DateTimeType extends ScalarType { diff --git a/GraphQL/Type/EdgeType.php b/GraphQL/Type/EdgeType.php index 4a0f1e3..9b78bfd 100644 --- a/GraphQL/Type/EdgeType.php +++ b/GraphQL/Type/EdgeType.php @@ -11,10 +11,10 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Type; +namespace Plugin\Api42\GraphQL\Type; use GraphQL\Type\Definition\ObjectType; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Types; class EdgeType extends ObjectType { diff --git a/GraphQL/Type/PageInfoType.php b/GraphQL/Type/PageInfoType.php index f66c697..6ee194d 100644 --- a/GraphQL/Type/PageInfoType.php +++ b/GraphQL/Type/PageInfoType.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL\Type; +namespace Plugin\Api42\GraphQL\Type; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; diff --git a/GraphQL/Types.php b/GraphQL/Types.php index 933a69c..78589eb 100644 --- a/GraphQL/Types.php +++ b/GraphQL/Types.php @@ -11,13 +11,13 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\GraphQL; +namespace Plugin\Api42\GraphQL; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\ClassMetadata; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; -use Plugin\Api\GraphQL\Type\Definition\DateTimeType; +use Plugin\Api42\GraphQL\Type\Definition\DateTimeType; /** * DoctrineのEntityからGraphQLのObjectTypeを変換するクラス. diff --git a/PluginManager.php b/PluginManager.php index 90e4c2b..30c80e5 100644 --- a/PluginManager.php +++ b/PluginManager.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api; +namespace Plugin\Api42; use Doctrine\ORM\EntityManager; use Eccube\Entity\AuthorityRole; diff --git a/Repository/WebHookRepository.php b/Repository/WebHookRepository.php index 0ff649d..9216e38 100644 --- a/Repository/WebHookRepository.php +++ b/Repository/WebHookRepository.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Repository; +namespace Plugin\Api42\Repository; -use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\Persistence\ManagerRegistry; use Eccube\Repository\AbstractRepository; -use Plugin\Api\Entity\WebHook; +use Plugin\Api42\Entity\WebHook; class WebHookRepository extends AbstractRepository { diff --git a/Resource/config/bundles.php b/Resource/config/bundles.php index e82d3b7..8e08335 100644 --- a/Resource/config/bundles.php +++ b/Resource/config/bundles.php @@ -12,6 +12,5 @@ */ return [ - Plugin\Api\Bundle\ApiBundle::class => ['all' => true], - Trikoder\Bundle\OAuth2Bundle\TrikoderOAuth2Bundle::class => ['all' => true], + Plugin\Api42\Bundle\ApiBundle::class => ['all' => true], ]; diff --git a/Resource/config/routes.php b/Resource/config/routes.php new file mode 100644 index 0000000..c7a50f5 --- /dev/null +++ b/Resource/config/routes.php @@ -0,0 +1,16 @@ +add('oauth2_authorize', '/%eccube_admin_route%/authorize') + ->controller(['league.oauth2_server.controller.authorization', 'indexAction']) + + ->add('oauth2_token', '/token') + ->controller(['league.oauth2_server.controller.token', 'indexAction']) + ->methods(['POST']) + ; +}; diff --git a/Resource/config/services.yaml b/Resource/config/services.yaml index 644920b..7f8f271 100644 --- a/Resource/config/services.yaml +++ b/Resource/config/services.yaml @@ -1,9 +1,12 @@ +security: + enable_authenticator_manager: true parameters: env(ECCUBE_OAUTH2_AUTHORIZATION_SERVER_PRIVATE_KEY): '%kernel.project_dir%/app/PluginData/Api/oauth/private.key' env(ECCUBE_OAUTH2_RESOURCE_SERVER_PUBLIC_KEY): '%kernel.project_dir%/app/PluginData/Api/oauth/public.key' env(ECCUBE_OAUTH2_ENCRYPTION_KEY): '' -trikoder_oauth2: +league_oauth2_server: + role_prefix: ROLE_OAUTH2_ authorization_server: private_key: '%env(ECCUBE_OAUTH2_AUTHORIZATION_SERVER_PRIVATE_KEY)%' @@ -28,21 +31,24 @@ trikoder_oauth2: resource_server: public_key: '%env(ECCUBE_OAUTH2_RESOURCE_SERVER_PUBLIC_KEY)%' - scopes: ['read', 'write'] +# scopes: ['read', 'write'] + scopes: + available: ['read', 'write'] + default: ['read'] persistence: doctrine: null services: - Plugin\Api\EventListener\UserResolveListener: + Plugin\Api42\EventListener\UserResolveListener: arguments: - '@Eccube\Security\Core\User\MemberProvider' - - '@Plugin\Api\Security\Core\Encoder\UserPasswordEncoder' + - '@Plugin\Api42\Security\Core\Encoder\UserPasswordEncoder' tags: - - { name: kernel.event_listener, event: trikoder.oauth2.user_resolve, method: onUserResolve } + - { name: kernel.event_listener, event: league.oauth2_server.event.user_resolve, method: onUserResolve } - Plugin\Api\GraphQL\Types: - class: Plugin\Api\GraphQL\Types + Plugin\Api42\GraphQL\Types: + class: Plugin\Api42\GraphQL\Types arguments: ["@doctrine.orm.entity_manager"] lazy: true @@ -68,9 +74,6 @@ services: nyholm.psr7.httplug_factory: class: Nyholm\Psr7\Factory\HttplugFactory - - Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory: '@sensio_framework_extra.psr7.http_message_factory' - core.api.allow_list: class: ArrayObject tags: ['eccube.api.allow_list'] @@ -144,8 +147,8 @@ services: api.mutations: class: ArrayObject - Plugin\Api\GraphQL\Schema: + Plugin\Api42\GraphQL\Schema: arguments: - - '@Plugin\Api\GraphQL\Types' + - '@Plugin\Api42\GraphQL\Types' - '@api.queries' - '@api.mutations' diff --git a/Resource/template/admin/OAuth/index.twig b/Resource/template/admin/OAuth/index.twig index 8f1e168..27ffbe2 100644 --- a/Resource/template/admin/OAuth/index.twig +++ b/Resource/template/admin/OAuth/index.twig @@ -123,7 +123,7 @@ file that was distributed with this source code. {% endfor %} - {% for grant in client.grants if grant != 'refresh_token' %} + {% for grant in client.grants|filter(grant => grant != 'refresh_token') %} {{ grant }}
{% endfor %} diff --git a/Security/Core/Encoder/UserPasswordEncoder.php b/Security/Core/Encoder/UserPasswordEncoder.php index deedf01..99ccdd5 100644 --- a/Security/Core/Encoder/UserPasswordEncoder.php +++ b/Security/Core/Encoder/UserPasswordEncoder.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Security\Core\Encoder; +namespace Plugin\Api42\Security\Core\Encoder; use Eccube\Security\Core\Encoder\PasswordEncoder; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; @@ -49,4 +49,12 @@ public function isPasswordValid(UserInterface $user, $raw) return $this->passwordEncoder->isPasswordValid($user->getPassword(), $raw, $user->getSalt()); } + + /** + * @inheritDoc + */ + public function needsRehash(UserInterface $user): bool + { + // TODO: Implement needsRehash() method. + } } diff --git a/Service/CoreEntityTrigger.php b/Service/CoreEntityTrigger.php index f63050f..d65081d 100644 --- a/Service/CoreEntityTrigger.php +++ b/Service/CoreEntityTrigger.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Service; +namespace Plugin\Api42\Service; use Eccube\Entity\Customer; use Eccube\Entity\CustomerAddress; diff --git a/Service/WebHookEvents.php b/Service/WebHookEvents.php index c0d92af..90905ef 100644 --- a/Service/WebHookEvents.php +++ b/Service/WebHookEvents.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Service; +namespace Plugin\Api42\Service; use Eccube\Entity\Customer; use Eccube\Entity\Order; diff --git a/Service/WebHookService.php b/Service/WebHookService.php index f209cfb..16c0cc2 100644 --- a/Service/WebHookService.php +++ b/Service/WebHookService.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Service; +namespace Plugin\Api42\Service; use Eccube\Util\StringUtil; use GuzzleHttp\Client; @@ -19,10 +19,10 @@ use GuzzleHttp\Pool; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; -use Plugin\Api\Entity\WebHook; -use Plugin\Api\Repository\WebHookRepository; +use Plugin\Api42\Entity\WebHook; +use Plugin\Api42\Repository\WebHookRepository; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent ; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\RouterInterface; @@ -60,7 +60,7 @@ public static function getSubscribedEvents() ]; } - public function fire(FilterResponseEvent $event) + public function fire(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/Service/WebHookTrigger.php b/Service/WebHookTrigger.php index 7546e2f..7071396 100644 --- a/Service/WebHookTrigger.php +++ b/Service/WebHookTrigger.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Service; +namespace Plugin\Api42\Service; interface WebHookTrigger { diff --git a/Tests/GraphQL/AllowListTest.php b/Tests/GraphQL/AllowListTest.php index b9bb534..7165701 100644 --- a/Tests/GraphQL/AllowListTest.php +++ b/Tests/GraphQL/AllowListTest.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\GraphQL; +namespace Plugin\Api42\Tests\GraphQL; use Eccube\Entity\Customer; use Eccube\Entity\Product; use PHPUnit\Framework\TestCase; -use Plugin\Api\GraphQL\AllowList; +use Plugin\Api42\GraphQL\AllowList; class AllowListTest extends TestCase { diff --git a/Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php b/Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php index 836c683..b21d5c7 100644 --- a/Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php +++ b/Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php @@ -11,14 +11,14 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\GraphQL\Mutation; +namespace Plugin\Api42\Tests\GraphQL\Mutation; use Eccube\Entity\ProductClass; use Eccube\Repository\ProductClassRepository; use Eccube\Tests\EccubeTestCase; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; -use Plugin\Api\GraphQL\Mutation\UpdateProductStockMutation; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Mutation\UpdateProductStockMutation; +use Plugin\Api42\GraphQL\Types; class UpdateProductStockMutationTest extends EccubeTestCase { @@ -28,7 +28,7 @@ class UpdateProductStockMutationTest extends EccubeTestCase /** @var UpdateProductStockMutation */ private $updateProductStockMutation; - public function setUp() + public function setUp(): void { parent::setUp(); $types = self::$container->get(Types::class); @@ -75,7 +75,7 @@ public function testUpdateProductStock($args, $expectStockUnlimited, $expectStoc self::assertEquals($expectStock, $ProductClass->getProductStock()->getStock()); } catch (InvalidArgumentException $e) { // エラーの確認 - self::assertRegExp($expectExeption, $e->getMessage()); + self::assertMatchesRegularExpression($expectExeption, $e->getMessage()); } // DBの確認 @@ -120,7 +120,7 @@ public function testUpdateProductStockMultiple() // 通らない self::assertTrue(false); } catch (InvalidArgumentException $e) { - self::assertRegExp('/Multiple ProductClass found/', $e->getMessage()); + self::assertMatchesRegularExpression('/Multiple ProductClass found/', $e->getMessage()); } } @@ -134,7 +134,7 @@ public function testUpdateProductStockNoData() // 通らない self::assertTrue(false); } catch (InvalidArgumentException $e) { - self::assertRegExp('/No ProductClass found/', $e->getMessage()); + self::assertMatchesRegularExpression('/No ProductClass found/', $e->getMessage()); } } } diff --git a/Tests/GraphQL/Mutation/UpdateShippedMutationTest.php b/Tests/GraphQL/Mutation/UpdateShippedMutationTest.php index 823bb06..201b8b2 100644 --- a/Tests/GraphQL/Mutation/UpdateShippedMutationTest.php +++ b/Tests/GraphQL/Mutation/UpdateShippedMutationTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\GraphQL\Mutation; +namespace Plugin\Api42\Tests\GraphQL\Mutation; use DateTime; use Eccube\Entity\Master\OrderStatus; @@ -22,9 +22,9 @@ use Eccube\Service\MailService; use Eccube\Service\OrderStateMachine; use Eccube\Tests\EccubeTestCase; -use Plugin\Api\GraphQL\Error\InvalidArgumentException; -use Plugin\Api\GraphQL\Mutation\UpdateShippedMutation; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Error\InvalidArgumentException; +use Plugin\Api42\GraphQL\Mutation\UpdateShippedMutation; +use Plugin\Api42\GraphQL\Types; class UpdateShippedMutationTest extends EccubeTestCase { @@ -38,7 +38,7 @@ class UpdateShippedMutationTest extends EccubeTestCase */ private $Order; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -119,7 +119,7 @@ public function testValidateArgs($args = [], string $message = null) } catch (InvalidArgumentException $e) { // エラーの確認 self::assertEquals('Invalid argument', $e->getCategory()); - self::assertRegExp($message, $e->getMessage()); + self::assertMatchesRegularExpression($message, $e->getMessage()); // Shipping が出荷済みになっていない self::assertNull($this->Order->getShippings()->current()->getShippingDate()); } @@ -164,7 +164,7 @@ public function testNoShippingFound() } catch (InvalidArgumentException $e) { // エラーの確認 self::assertEquals('Invalid argument', $e->getCategory()); - self::assertRegExp('/No Shipping found/', $e->getMessage()); + self::assertMatchesRegularExpression('/No Shipping found/', $e->getMessage()); } } @@ -188,7 +188,7 @@ public function testAlreadyShipped() } catch (InvalidArgumentException $e) { // エラーの確認 self::assertEquals('Invalid argument', $e->getCategory()); - self::assertRegExp('/Already shipped/', $e->getMessage()); + self::assertMatchesRegularExpression('/Already shipped/', $e->getMessage()); } } @@ -211,7 +211,7 @@ public function testOrderCannotBeShipped() } catch (InvalidArgumentException $e) { // エラーの確認 self::assertEquals('Invalid argument', $e->getCategory()); - self::assertRegExp('/order cannot be shipped/', $e->getMessage()); + self::assertMatchesRegularExpression('/order cannot be shipped/', $e->getMessage()); } } diff --git a/Tests/GraphQL/SchemaTest.php b/Tests/GraphQL/SchemaTest.php index 5c8481f..969a663 100644 --- a/Tests/GraphQL/SchemaTest.php +++ b/Tests/GraphQL/SchemaTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\GraphQL; +namespace Plugin\Api42\Tests\GraphQL; use Eccube\Entity\Master\OrderStatus; use Eccube\Tests\EccubeTestCase; @@ -20,7 +20,7 @@ use GraphQL\Server\Helper; use GraphQL\Server\OperationParams; use GraphQL\Server\ServerConfig; -use Plugin\Api\GraphQL\Schema; +use Plugin\Api42\GraphQL\Schema; class SchemaTest extends EccubeTestCase { @@ -264,7 +264,7 @@ public function testQueryWithPagination($page, $limit, $expectedErrorMessage = n $result = $this->executeQuery($query); if ($expectedErrorMessage) { - self::assertRegExp($expectedErrorMessage, $result['errors'][0]['message']); + self::assertMatchesRegularExpression($expectedErrorMessage, $result['errors'][0]['message']); } else { self::assertFalse(isset($result['errors'])); } @@ -289,7 +289,7 @@ public function testQueryWithDateTime($dateTime, $expectedErrorMessage = null) $result = $this->executeQuery($query); if ($expectedErrorMessage) { - self::assertRegExp($expectedErrorMessage, $result['errors'][0]['message']); + self::assertMatchesRegularExpression($expectedErrorMessage, $result['errors'][0]['message']); } else { self::assertFalse(isset($result['errors'])); } diff --git a/Tests/GraphQL/TypesTest.php b/Tests/GraphQL/TypesTest.php index 262f32e..c1293f7 100644 --- a/Tests/GraphQL/TypesTest.php +++ b/Tests/GraphQL/TypesTest.php @@ -11,21 +11,21 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\GraphQL; +namespace Plugin\Api42\Tests\GraphQL; use Eccube\Entity\BaseInfo; use Eccube\Entity\Customer; use Eccube\Entity\Member; use Eccube\Entity\Product; use Eccube\Tests\EccubeTestCase; -use Plugin\Api\GraphQL\Types; +use Plugin\Api42\GraphQL\Types; class TypesTest extends EccubeTestCase { /** @var Types */ private $types; - public function setUp() + public function setUp(): void { parent::setUp(); $this->types = self::$container->get(Types::class); diff --git a/Tests/Service/WebHookServiceTest.php b/Tests/Service/WebHookServiceTest.php index e3a93eb..ad281b5 100644 --- a/Tests/Service/WebHookServiceTest.php +++ b/Tests/Service/WebHookServiceTest.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\Service; +namespace Plugin\Api42\Tests\Service; use Eccube\Tests\EccubeTestCase; use Nyholm\Psr7\Request; -use Plugin\Api\Entity\WebHook; -use Plugin\Api\Service\WebHookService; +use Plugin\Api42\Entity\WebHook; +use Plugin\Api42\Service\WebHookService; use ReflectionClass; use ReflectionException; @@ -25,7 +25,7 @@ class WebHookServiceTest extends EccubeTestCase /** @var WebHookService */ private $service; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/Tests/Web/Admin/LoginControllerTest.php b/Tests/Web/Admin/LoginControllerTest.php index 0d44cae..4bafe9f 100644 --- a/Tests/Web/Admin/LoginControllerTest.php +++ b/Tests/Web/Admin/LoginControllerTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\Web\Admin; +namespace Plugin\Api42\Tests\Web\Admin; use Eccube\Tests\Web\AbstractWebTestCase; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; diff --git a/Tests/Web/Admin/OAuth2Bundle/AuthorizationControllerTest.php b/Tests/Web/Admin/OAuth2Bundle/AuthorizationControllerTest.php index 4087428..1f04625 100644 --- a/Tests/Web/Admin/OAuth2Bundle/AuthorizationControllerTest.php +++ b/Tests/Web/Admin/OAuth2Bundle/AuthorizationControllerTest.php @@ -11,16 +11,16 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\Web\Admin\OAuth2Bundle; +namespace Plugin\Api42\Tests\Web\Admin\OAuth2Bundle; use Eccube\Common\Constant; use Eccube\Tests\Web\Admin\AbstractAdminWebTestCase; use Symfony\Component\HttpFoundation\Response; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; +use League\Bundle\OAuth2ServerBundle\Model\Client; class AuthorizationControllerTest extends AbstractAdminWebTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/Tests/Web/Admin/OAuthControllerTest.php b/Tests/Web/Admin/OAuthControllerTest.php index ded8e05..36b3866 100644 --- a/Tests/Web/Admin/OAuthControllerTest.php +++ b/Tests/Web/Admin/OAuthControllerTest.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\Web\Admin; +namespace Plugin\Api42\Tests\Web\Admin; use Eccube\Tests\Web\Admin\AbstractAdminWebTestCase; -use Trikoder\Bundle\OAuth2Bundle\Manager\Doctrine\ClientManager; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; -use Trikoder\Bundle\OAuth2Bundle\OAuth2Grants; +use League\Bundle\OAuth2ServerBundle\Manager\Doctrine\ClientManager; +use League\Bundle\OAuth2ServerBundle\Model\Client; +use League\Bundle\OAuth2ServerBundle\OAuth2Grants; class OAuthControllerTest extends AbstractAdminWebTestCase { @@ -28,7 +28,7 @@ class OAuthControllerTest extends AbstractAdminWebTestCase /** * @{@inheritdoc} */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -64,7 +64,7 @@ public function testRoutingAdminSettingSystemOAuth2ClientDelete() $this->assertNull($this->clientManager->find($identifier)); $crawler = $this->client->followRedirect(); - $this->assertRegExp('/削除しました/u', $crawler->filter('div.alert-success')->text()); + $this->assertMatchesRegularExpression('/削除しました/u', $crawler->filter('div.alert-success')->text()); } public function testOAuth2ClientCreateSubmit() @@ -99,7 +99,7 @@ public function testOAuth2ClientCreateSubmit() $this->assertTrue(in_array(OAuth2Grants::REFRESH_TOKEN, $grants)); $crawler = $this->client->followRedirect(); - $this->assertRegExp('/保存しました/u', $crawler->filter('div.alert-success')->text()); + $this->assertMatchesRegularExpression('/保存しました/u', $crawler->filter('div.alert-success')->text()); } public function testOAuth2ClientCreateSubmitFail() @@ -118,7 +118,7 @@ public function testOAuth2ClientCreateSubmitFail() $this->assertTrue($this->client->getResponse()->isSuccessful()); - $this->assertRegExp('/入力されていません。/u', $crawler->filter('span.form-error-message')->text()); + $this->assertMatchesRegularExpression('/入力されていません。/u', $crawler->filter('span.form-error-message')->text()); } public function testOAuth2ClientDeleteIdentifierNotFound() @@ -135,7 +135,7 @@ public function testOAuth2ClientDeleteIdentifierNotFound() $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); $crawler = $this->client->followRedirect(); - $this->assertRegExp('/既に削除されています/u', $crawler->filter('div.alert-danger')->text()); + $this->assertMatchesRegularExpression('/既に削除されています/u', $crawler->filter('div.alert-danger')->text()); } protected function createFormData() diff --git a/Tests/Web/ApiControllerTest.php b/Tests/Web/ApiControllerTest.php index a445601..107669b 100644 --- a/Tests/Web/ApiControllerTest.php +++ b/Tests/Web/ApiControllerTest.php @@ -11,17 +11,17 @@ * file that was distributed with this source code. */ -namespace Plugin\Api\Tests\Web; +namespace Plugin\Api42\Tests\Web; use DateTime; use Eccube\Tests\Web\AbstractWebTestCase; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; -use Trikoder\Bundle\OAuth2Bundle\League\Entity\AccessToken; -use Trikoder\Bundle\OAuth2Bundle\League\Entity\Scope; -use Trikoder\Bundle\OAuth2Bundle\Manager\Doctrine\ClientManager; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; +use League\Bundle\OAuth2ServerBundle\Entity\AccessToken; +use League\Bundle\OAuth2ServerBundle\Entity\Scope; +use League\Bundle\OAuth2ServerBundle\Manager\Doctrine\ClientManager; +use League\Bundle\OAuth2ServerBundle\Model\Client; class ApiControllerTest extends AbstractWebTestCase { @@ -37,7 +37,7 @@ class ApiControllerTest extends AbstractWebTestCase /** @var AuthorizationServer */ private $authorizationServer; - public function setUp() + public function setUp(): void { parent::setUp(); $this->clientManager = self::$container->get(ClientManager::class); @@ -89,7 +89,7 @@ private function newAccessToken($scopes) $client = new Client($identifier, $secret); $client->setScopes(...array_map(function ($s) { - return new \Trikoder\Bundle\OAuth2Bundle\Model\Scope($s); + return new League\Bundle\OAuth2ServerBundle\ValueObject\Scope($s); }, $scopes)); $this->clientManager->save($client); $clientEntity = $this->clientRepository->getClientEntity($identifier, 'authorization_code', $secret); diff --git a/composer.json b/composer.json index 029e3c9..a2ef62f 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { - "name": "ec-cube/api", - "version": "2.1.3", + "name": "ec-cube/api42", + "version": "4.2.0", "description": "Web API", "type": "eccube-plugin", "require": { - "ec-cube/plugin-installer": "~0.0.6 || ^2.0", - "trikoder/oauth2-bundle": "^2.1", + "ec-cube/plugin-installer": "^2.0", + "league/oauth2-server-bundle": "^0.3", "nyholm/psr7": "^1.2", "webonyx/graphql-php": "^14.0" }, "extra": { - "code": "Api", - "entity-namespaces": ["Trikoder\\Bundle\\OAuth2Bundle\\Model"] + "code": "Api42", + "entity-namespaces": ["League\\Bundle\\OAuth2ServerBundle\\Model"] } } diff --git a/docs/_pages/customize/query.md b/docs/_pages/customize/query.md index 1c9cc25..a63877e 100644 --- a/docs/_pages/customize/query.md +++ b/docs/_pages/customize/query.md @@ -4,7 +4,7 @@ permalink: /customize/query ## Query/Mutationの追加 -Query は `Plugin\Api\GraphQL\Query` インタフェースを、 Mutation は `Plugin\Api\GraphQL\Mutation` インタフェースを実装したクラスを作成することで Query/Mutation の追加が可能です。 +Query は `Plugin\Api42\GraphQL\Query` インタフェースを、 Mutation は `Plugin\Api42\GraphQL\Mutation` インタフェースを実装したクラスを作成することで Query/Mutation の追加が可能です。 `Hello Query!` の文字列を返す最小のQueryの実装例は以下です。 @@ -14,7 +14,7 @@ Query は `Plugin\Api\GraphQL\Query` インタフェースを、 Mutation は `P namespace Customize\GraphQL\Query; use GraphQL\Type\Definition\Type; -use Plugin\Api\GraphQL\Query; +use Plugin\Api42\GraphQL\Query; class HelloQuery implements Query { @@ -57,4 +57,4 @@ query { ### 参考 -プラグインのデフォルトの Query および Mutation の実装は `Api/GraphQL/Query` および `Api/GraphQL/Mutation` にあります。 +プラグインのデフォルトの Query および Mutation の実装は `Api42/GraphQL/Query` および `Api42/GraphQL/Mutation` にあります。 diff --git a/docs/_pages/quickstart.md b/docs/_pages/quickstart.md index 010029e..9128ad1 100644 --- a/docs/_pages/quickstart.md +++ b/docs/_pages/quickstart.md @@ -55,8 +55,8 @@ permalink: /quickstart 1. プラグインをインストールします。 ```sh - bin/console eccube:composer:require ec-cube/Api - bin/console eccube:plugin:enable --code=Api + bin/console eccube:composer:require ec-cube/Api42 + bin/console eccube:plugin:enable --code=Api42 ``` - 管理画面→オーナーズストア→プラグイン→ **プラグインを探す** からでもプラグインをインストールできます。 diff --git a/docs/_pages/webhook.md b/docs/_pages/webhook.md index 6f03910..c13a12f 100644 --- a/docs/_pages/webhook.md +++ b/docs/_pages/webhook.md @@ -53,7 +53,7 @@ curl \ #### 上記以外のEntityで発火させるカスタマイズ -プラグインやカスタマイズで上記以外の Entity で発火させたい場合は、 `Plugin\Api\Service\WebHookTrigger` インターフェイスを実装したクラスを定義します。 +プラグインやカスタマイズで上記以外の Entity で発火させたい場合は、 `Plugin\Api42\Service\WebHookTrigger` インターフェイスを実装したクラスを定義します。 ### 対象のアクション diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f94f8ee..c77d321 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,6 +13,7 @@ +