bitexpert / sylius-2fa-plugin
Sylius 2FA Plugin
Installs: 48
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Type:sylius-plugin
pkg:composer/bitexpert/sylius-2fa-plugin
Requires
- php: ^8.2
- endroid/qr-code-bundle: ^6.0
- scheb/2fa-bundle: ^7.11
- scheb/2fa-email: ^7.13
- scheb/2fa-google-authenticator: ^7.11
- sylius/sylius: ^2.1
Requires (Dev)
- behat/behat: ^3.16
- bitexpert/phpstan-sylius: ^0.2.0
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- ergebnis/composer-normalize: ^2.48
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- madewithlove/license-checker: ^2.1
- nyholm/psr7: ^1.8
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^10.5
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ^0.2
- sylius/sylius-rector: ^3.7
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^7.4
- symfony/debug-bundle: ^7.4
- symfony/dotenv: ^7.4
- symfony/http-client: ^7.4
- symfony/intl: ^7.4
- symfony/runtime: ^7.4
- symfony/web-profiler-bundle: ^7.4
- symfony/webpack-encore-bundle: ^2.2
- vincentlanglet/twig-cs-fixer: ^3.11
Conflicts
- symfony/flex: <2.2
- symplify/easy-coding-standard: <12.0
- thecodingmachine/safe: <2.0
This package is auto-updated.
Last update: 2026-02-01 08:44:27 UTC
README
Requirements:
- PHP 8.2 or higher
- Sylius 2.0 or higher
Installation
- Install the plugin via Composer
composer require bitexpert/sylius-2fa-plugin
- Enable the plugin
<?php # config/bundles.php return [ // ... Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true], Endroid\QrCodeBundle\EndroidQrCodeBundle::class => ['all' => true], BitExpert\SyliusTwoFactorAuthPlugin\BitExpertSyliusTwoFactorAuthPlugin::class => ['all' => true], ];
- Import config
# config/packages/_sylius.yaml imports: # ... - { resource: "@BitExpertSyliusTwoFactorAuthPlugin/config/config.yaml" } # ...
- Import routing
# config/routes/bitexpert_sylius_2fa.yaml bitexpert_sylius_2fa_admin: resource: "@BitExpertSyliusTwoFactorAuthPlugin/config/routes/admin.yaml" prefix: /%sylius_admin.path_name% bitexpert_sylius_2fa_shop: resource: "@BitExpertSyliusTwoFactorAuthPlugin/config/routes/shop.yaml" prefix: /{_locale}
- Update firewall configuration
Add the two_factor configuration to your admin firewall configuration.
# config/packages/security.yaml security: firewalls: admin: two_factor: auth_form_path: bitexpert_sylius_2fa_admin_login check_path: bitexpert_sylius_2fa_admin_login_check multi_factor: false
Add the two_factor configuration to your shop firewall configuration.
# config/packages/security.yaml security: firewalls: shop: two_factor: auth_form_path: bitexpert_sylius_2fa_shop_login check_path: bitexpert_sylius_2fa_shop_login_check multi_factor: false
- Configure
AdminUserentity in filesrc/Entity/User/AdminUser.php
Add the BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthInterface interface and the BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthTrait trait to the entity.
<?php declare(strict_types=1); namespace App\Entity\User; use BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthInterface; use BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\AdminUser as BaseAdminUser; #[ORM\Entity] #[ORM\Table(name: 'sylius_admin_user')] class AdminUser extends BaseAdminUser implements TwoFactorAuthInterface { use TwoFactorAuthTrait; }
- Configure
ShopUserentity in filesrc/Entity/User/ShopUser.php
Add the BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthInterface interface and the BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthTrait trait to the entity.
<?php declare(strict_types=1); namespace App\Entity\User; use BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthInterface; use BitExpert\SyliusTwoFactorAuthPlugin\Entity\TwoFactorAuthTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\ShopUser as BaseShopUser; #[ORM\Entity] #[ORM\Table(name: 'sylius_shop_user')] class ShopUser extends BaseShopUser implements TwoFactorAuthInterface { use TwoFactorAuthTrait; }
- Update your database schema
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Tests
You can run the unit tests with the following command (requires dependency installation):
./vendor/bin/phpunit
Contribution
Feel free to contribute to this module by reporting issues or create some pull requests for improvements.
To run the Test Application included in the repo, refer to the Sylius Test Application docs. If you are using DDEV you can run the following command to bootstrap the Test Application in Docker:
ddev start
License
The Sylius 2FA Plugin for Sylius is released under the MIT license.