From 5aed2ec53b8c143e2c0274180e67de6ad23bfaa0 Mon Sep 17 00:00:00 2001 From: Valentin Silvestre Date: Thu, 22 Dec 2022 13:53:24 +0100 Subject: [PATCH] Update to Symfony 6 --- .github/workflows/build.yml | 56 +---------- composer.json | 34 ++++--- spec/Exporter/ResourceExporterSpec.php | 2 +- .../Handler/ArrayToStringHandlerSpec.php | 2 +- .../Handler/DateTimeToStringHandlerSpec.php | 2 +- .../IntegerToMoneyFormatHandlerSpec.php | 4 +- spec/Exporter/Transformer/PoolSpec.php | 4 +- spec/Importer/JsonResourceImporterSpec.php | 2 +- spec/Importer/ResourceImporterSpec.php | 2 +- src/Controller/ImportDataController.php | 5 +- .../ParameterBag/ParameterBag.php | 6 +- .../Handler/IntegerToMoneyFormatHandler.php | 4 +- src/Resources/config/services.yml | 2 +- tests/Application/Kernel.php | 37 ++----- tests/Application/config/bootstrap.php | 4 + tests/Application/config/bundles.php | 2 - .../Application/config/packages/_sylius.yaml | 1 - .../Application/config/packages/security.yaml | 96 +++++++------------ .../config/packages/security_checker.yaml | 9 -- .../config/packages/test/framework.yaml | 2 +- .../config/packages/test/security.yaml | 7 +- .../packages/test_cached/framework.yaml | 6 +- .../config/packages/test_cached/security.yaml | 5 +- .../config/routes/sylius_admin_api.yaml | 3 - tests/Application/package.json | 43 +++------ 25 files changed, 107 insertions(+), 233 deletions(-) delete mode 100644 tests/Application/config/packages/security_checker.yaml delete mode 100644 tests/Application/config/routes/sylius_admin_api.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d417c91..59603a29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,61 +21,16 @@ jobs: strategy: fail-fast: false matrix: - php: [7.3, 7.4, 8.0, 8.1] - symfony: [^4.4, ^5.4, ^6.0] - sylius: [~1.8.0, ~1.9.0, ~1.10.0, ~1.11.0, ~1.12.x-dev] + php: [8.0, 8.1] + symfony: [^5.4, ^6.0] + sylius: [~1.11.0, ~1.12.0] node: [14.x] mysql: [5.7] exclude: - - - sylius: ~1.8.0 - symfony: ^5.4 - - - sylius: ~1.8.0 - symfony: ^6.0 - - - sylius: ~1.9.0 - symfony: ^6.0 - - - sylius: ~1.10.0 - symfony: ^6.0 - sylius: ~1.11.0 symfony: ^6.0 - - - sylius: ~1.8.0 - symfony: ^6.0 - - - sylius: ~1.12.x-dev - symfony: ^4.4 - - - sylius: ~1.8.0 - php: 8.0 - - - sylius: ~1.9.0 - php: 8.0 - - - sylius: ~1.8.0 - php: 8.1 - - - sylius: ~1.9.0 - php: 8.1 - - - sylius: ~1.10.0 - php: 7.3 - - - sylius: ~1.11.0 - php: 7.3 - - - sylius: ~1.11.0 - php: 7.4 - - - sylius: ~1.12.x-dev - php: 7.3 - - - sylius: ~1.12.x-dev - php: 7.4 env: APP_ENV: test @@ -154,11 +109,6 @@ jobs: if: matrix.sylius != '' run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction - - - name: Add Admin API Bundle for Sylius >= 1.10 - if: matrix.sylius != '~1.8.0' && matrix.sylius != '~1.9.0' - run: composer require sylius/admin-api-bundle --no-update --no-scripts --no-interaction - - name: Install PHP dependencies run: composer install --no-interaction diff --git a/composer.json b/composer.json index a79ae804..76a3273f 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,11 @@ "description": "import / export plugin for Sylius.", "license": "MIT", "require": { - "sylius/sylius": "^1.8", + "php": "^8.0", + "sylius/sylius": "~1.11.0 || ~1.12.0", "portphp/portphp": "^1.2", - "symfony/stopwatch": "^4.4 || ^5.2", - "queue-interop/queue-interop": "^0.6.2 || ^0.7 || ^0.8" + "queue-interop/queue-interop": "^0.6.2 || ^0.7 || ^0.8", + "symfony/stopwatch": "^5.2 || ^6.0" }, "suggest": { "portphp/spreadsheet": "To support importing Excel and LibreOffice Calc files, use version ^1.1", @@ -17,18 +18,17 @@ "enqueue/sqs" : "To support message queuing via sqs" }, "require-dev": { - "behat/behat": "^3.6.1", - "behat/mink": "^1.8", - "behat/mink-selenium2-driver": "^1.3", + "behat/behat": "^3.7", + "behat/mink-selenium2-driver": "^1.4", "enqueue/redis": "^0.8.23", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", + "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/mink-debug-extension": "^2.0", + "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/page-object-extension": "^0.3", "friends-of-behat/suite-settings-extension": "^1.0", - "friends-of-behat/symfony-extension": "^2.2", - "friends-of-behat/variadic-extension": "^1.1", + "friends-of-behat/symfony-extension": "^2.1", + "friends-of-behat/variadic-extension": "^1.3", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "0.12.82", @@ -36,16 +36,14 @@ "phpstan/phpstan-strict-rules": "^0.12.0", "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", - "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^3.2 || ^4.0", - "symfony/browser-kit": "^4.4 || ^5.2", - "symfony/debug-bundle": "^4.4 || ^5.2", - "symfony/dotenv": "^4.4 || ^5.2", - "symfony/intl": "^4.4 || ^5.2", - "symfony/mailer": "^4.4 || ^5.2", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", + "symfony/intl": "^5.4 || ^6.0", + "symfony/mailer": "^5.4 || ^6.0", "symfony/webpack-encore-bundle": "^1.15", - "symfony/web-profiler-bundle": "^4.4 || ^5.2", - "symfony/web-server-bundle": "^4.4 || ^5.2", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", "portphp/csv": "^1.1.0", "portphp/spreadsheet": "^1.0.0-alpha", "predis/predis": "^1.1" diff --git a/spec/Exporter/ResourceExporterSpec.php b/spec/Exporter/ResourceExporterSpec.php index 256d5060..f9b97c93 100644 --- a/spec/Exporter/ResourceExporterSpec.php +++ b/spec/Exporter/ResourceExporterSpec.php @@ -40,7 +40,7 @@ function it_should_export_but_also_transform( PluginInterface $plugin ) { $generator = new RewindableGenerator(function () { - return [new DateTimeToStringHandler()]; + yield new DateTimeToStringHandler(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php b/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php index e02d2f4a..759a4348 100644 --- a/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php @@ -41,7 +41,7 @@ function it_should_process_via_pool() $array = ['a', 'b', 'c']; $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php b/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php index bf3b693e..881011ac 100644 --- a/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php @@ -41,7 +41,7 @@ function it_should_process_via_pool() $date = \DateTime::createFromFormat('Y-m-d', '2018-01-01'); $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php b/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php index 68bea55d..297ba1c0 100644 --- a/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php @@ -9,6 +9,7 @@ use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\HandlerInterface; use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\Pool; use PhpSpec\ObjectBehavior; +use Prophecy\Prophet; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Webmozart\Assert\Assert; @@ -38,12 +39,13 @@ function it_should_process_directly() { $this->handle('test', 10000)->shouldBeString(); $this->handle('test', 12345)->shouldBe('123.45'); + $this->handle('test', 987654)->shouldBe('9876.54'); } function it_should_process_via_pool() { $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/PoolSpec.php b/spec/Exporter/Transformer/PoolSpec.php index e720ff93..2dac51b2 100644 --- a/spec/Exporter/Transformer/PoolSpec.php +++ b/spec/Exporter/Transformer/PoolSpec.php @@ -24,8 +24,8 @@ function it_should_implement_interface() function let(HandlerInterface $dateTimeToStringHandler) { - $generator = new RewindableGenerator(function () use ($dateTimeToStringHandler) { - return [$dateTimeToStringHandler]; + $generator = new RewindableGenerator(function () use ($dateTimeToStringHandler): \Traversable { + yield $dateTimeToStringHandler; }, $count = 1); $this->beConstructedWith($generator); diff --git a/spec/Importer/JsonResourceImporterSpec.php b/spec/Importer/JsonResourceImporterSpec.php index 5d826119..61e9e66c 100644 --- a/spec/Importer/JsonResourceImporterSpec.php +++ b/spec/Importer/JsonResourceImporterSpec.php @@ -4,7 +4,7 @@ namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\JsonResourceImporter; diff --git a/spec/Importer/ResourceImporterSpec.php b/spec/Importer/ResourceImporterSpec.php index 0ebc28f4..3b3f9428 100644 --- a/spec/Importer/ResourceImporterSpec.php +++ b/spec/Importer/ResourceImporterSpec.php @@ -4,7 +4,7 @@ namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface; diff --git a/src/Controller/ImportDataController.php b/src/Controller/ImportDataController.php index 7db356a1..60ad2985 100644 --- a/src/Controller/ImportDataController.php +++ b/src/Controller/ImportDataController.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Twig\Environment; @@ -35,14 +36,14 @@ final class ImportDataController public function __construct( ServiceRegistryInterface $registry, - FlashBagInterface $flashBag, + RequestStack $requestStack, FormFactoryInterface $formFactory, Environment $twig ) { $this->registry = $registry; $this->formFactory = $formFactory; $this->twig = $twig; - $this->flashBag = $flashBag; + $this->flashBag = $requestStack->getCurrentRequest()->getSession()->getFlashBag(); } public function importFormAction(Request $request): Response diff --git a/src/DependencyInjection/ParameterBag/ParameterBag.php b/src/DependencyInjection/ParameterBag/ParameterBag.php index 1928191b..27e0070c 100644 --- a/src/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/DependencyInjection/ParameterBag/ParameterBag.php @@ -26,7 +26,7 @@ public function __construct(Container $container) /** * {@inheritdoc} */ - public function all() + public function all(): array { return $this->container->getParameterBag()->all(); } @@ -34,7 +34,7 @@ public function all() /** * {@inheritdoc} */ - public function get($name) + public function get($name): array|bool|string|int|float|\UnitEnum|null { return $this->container->getParameter($name); } @@ -42,7 +42,7 @@ public function get($name) /** * {@inheritdoc} */ - public function has($name) + public function has($name): bool { return $this->container->hasParameter($name); } diff --git a/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php b/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php index 280ac674..eb11597e 100644 --- a/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php +++ b/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php @@ -17,7 +17,7 @@ final class IntegerToMoneyFormatHandler extends Handler /** * @param string[] $allowedKeys */ - public function __construct(array $allowedKeys, string $format = '%.2n') + public function __construct(array $allowedKeys, string $format = '%0.2f') { $this->keys = $allowedKeys; $this->format = $format; @@ -28,7 +28,7 @@ public function __construct(array $allowedKeys, string $format = '%.2n') */ protected function process($key, $value): ?string { - return money_format($this->format, $value / 100); + return sprintf($this->format, $value / 100); } protected function allows($key, $value): bool diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 5c703673..7b49904e 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -11,7 +11,7 @@ services: class: FriendsOfSylius\SyliusImportExportPlugin\Controller\ImportDataController arguments: - "@sylius.importers_registry" - - "@session.flash_bag" + - "@request_stack" - "@form.factory" - "@twig" tags: ['controller.service_arguments'] diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 7ee3ef2a..ed89cddf 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; final class Kernel extends BaseKernel { @@ -41,24 +41,7 @@ public function registerBundles(): iterable } } - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $bundlesFile = $confDir . '/bundles.php'; - if (false === is_file($bundlesFile)) { - continue; - } - $container->addResource(new FileResource($bundlesFile)); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -79,19 +62,11 @@ private function isTestEnvironment(): bool return 0 === strpos($this->getEnvironment(), 'test'); } - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - - private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void + private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); } /** diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index e23eca03..c9951a7c 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -13,6 +13,10 @@ $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} elseif (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + + return; } else { // load all the .env files (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index e416a3b5..d6248e58 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -46,8 +46,6 @@ Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], FriendsOfSylius\SyliusImportExportPlugin\FOSSyliusImportExportPlugin::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 79f5ce6c..7532b01a 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -2,7 +2,6 @@ imports: - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 12e842b8..aa9cbfbb 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,12 +1,5 @@ -parameters: - sylius.security.admin_regex: "^/admin" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - security: - always_authenticate_before_granting: true + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -16,11 +9,8 @@ security: id: sylius.shop_user_provider.email_or_name_based sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -36,69 +26,44 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: secret: "%env(APP_SECRET)%" - path: /admin + path: "/%sylius_admin.path_name%" name: APP_ADMIN_REMEMBER_ME lifetime: 31536000 remember_me_parameter: _remember_me logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + check_path: "%sylius.security.new_api_admin_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + check_path: "%sylius.security.new_api_shop_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: true + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -115,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -125,28 +90,35 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + image_resolver: + pattern: ^/media/cache/resolve security: false access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } \ No newline at end of file diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100644 index 0f9cf00f..00000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e1..fc1d3c13 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc3772..3949f0d9 100644 --- a/tests/Application/config/packages/test/security.yaml +++ b/tests/Application/config/packages/test/security.yaml @@ -1,3 +1,6 @@ security: - encoders: - sha512: sha512 + password_hashers: + Sylius\Component\User\Model\UserInterface: + algorithm: argon2i + time_cost: 3 + memory_cost: 10 \ No newline at end of file diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e1..e9dd6eea 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,2 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml index 21cc3772..76e9273f 100644 --- a/tests/Application/config/packages/test_cached/security.yaml +++ b/tests/Application/config/packages/test_cached/security.yaml @@ -1,3 +1,2 @@ -security: - encoders: - sha512: sha512 +imports: + - { resource: ../test/security.yaml } diff --git a/tests/Application/config/routes/sylius_admin_api.yaml b/tests/Application/config/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed457..00000000 --- a/tests/Application/config/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/package.json b/tests/Application/package.json index e726741b..b85e2fff 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,6 +1,5 @@ { "dependencies": { - "@babel/polyfill": "^7.0.0", "chart.js": "^3.7.1", "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", @@ -10,53 +9,41 @@ }, "devDependencies": { "@babel/core": "^7.0.0", - "@babel/plugin-external-helpers": "^7.0.0", + "@babel/eslint-parser": "^7.19.1", "@babel/plugin-proposal-object-rest-spread": "^7.18.9", "@babel/preset-env": "^7.18.10", - "@babel/register": "^7.0.0", - "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-commonjs": "^22.0.2", - "@rollup/plugin-inject": "^4.0.4", - "@rollup/plugin-node-resolve": "^13.3.0", + "@babel/register": "^7.18.9", + "@rollup/plugin-babel": "^6.0.3", + "@rollup/plugin-commonjs": "^23.0.3", + "@rollup/plugin-inject": "^5.0.2", + "@rollup/plugin-node-resolve": "^15.0.1", "@semantic-ui-react/css-patch": "^1.1.2", - "@symfony/webpack-encore": "^3.1.0", + "@symfony/webpack-encore": "^4.0.0", "babel-plugin-fast-async": "^6.1.2", "babel-plugin-module-resolver": "^4.1.0", "dedent": "^0.7.0", - "eslint": "^8.23.0", + "eslint": "^8.28.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-import-resolver-babel-module": "^5.3.1", + "eslint-import-resolver-webpack": "^0.13.2", "eslint-plugin-import": "^2.26.0", + "eslint-webpack-plugin": "^3.2.0", "fast-async": "^6.3.8", - "gulp": "^4.0.2", - "gulp-chug": "^0.5.1", - "gulp-concat": "^2.6.1", - "gulp-debug": "^4.0.0", - "gulp-if": "^3.0.0", - "gulp-livereload": "^4.0.2", - "gulp-order": "^1.2.0", - "gulp-sass": "^5.1.0", - "gulp-sourcemaps": "^3.0.0", - "gulp-uglifycss": "^1.1.0", "merge-stream": "^2.0.0", - "rollup": "^2.79.0", + "rollup": "^2.79.1", "rollup-plugin-terser": "^7.0.2", - "sass": "^1.54.8", + "sass": "^1.56.1", "sass-loader": "^13.0.0", - "upath": "^2.0.1", - "yargs": "^17.5.1" - }, - "engines": { - "node": "^14 || ^16 || ^18" + "webpack": "^5.75.0", + "webpack-cli": "^4.10.0" }, "engineStrict": true, "scripts": { "watch": "encore dev --watch", "build": "encore dev", "build:prod": "encore production", - "gulp": "gulp build", "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js src/Sylius/Bundle/AdminBundle/gulpfile.babel.js src/Sylius/Bundle/ShopBundle/gulpfile.babel.js src/Sylius/Bundle/UiBundle/Resources/private/js src/Sylius/Bundle/AdminBundle/Resources/private/js src/Sylius/Bundle/ShopBundle/Resources/private/js", + "lint:js": "eslint webpack.config.js assets/admin assets/shop", "postinstall": "semantic-ui-css-patch" }, "repository": {