Two-factor sign-in for the Sylius 2 admin panel: authenticator-app codes (TOTP), one-time backup codes, lockout after wrong codes, optional enforcement for every administrator and admin API protection.
Protect your Sylius 2 admin panel with two-factor authentication (2FA). Administrators sign in with their password plus a 6-digit code from an authenticator app, with one-time backup codes as a fallback.
1. Require the plugin
composer require buildwebproject/sylius-admin-two-factor-plugin
2. Register the bundle in config/bundles.php (Symfony Flex does not do this for Sylius plugins):
BuildWebProject\SyliusAdminTwoFactorPlugin\BuildWebProjectSyliusAdminTwoFactorPlugin::class => ['all' => true],
3. Create config/packages/buildwebproject_sylius_admin_two_factor.yaml:
imports:
- { resource: "@BuildWebProjectSyliusAdminTwoFactorPlugin/config/config.yaml" }
buildwebproject_sylius_admin_two_factor:
enabled: true
4. Create config/routes/buildwebproject_sylius_admin_two_factor.yaml:
buildwebproject_sylius_admin_two_factor:
resource: "@BuildWebProjectSyliusAdminTwoFactorPlugin/config/routes/admin.yaml"
prefix: /%sylius_admin.path_name%
5. Run the migration and clear the cache:
bin/console doctrine:migrations:migrate -n bin/console cache:clear
6. Sign in to the admin panel, click the shield icon in the top bar and choose Set up two-factor sign-in.
Check your APP_SECRET first. The plugin derives its encryption key from kernel.secret and refuses keys shorter than 16 characters. Sylius-Standard ships a committed .env.prod with a placeholder APP_SECRET, which overrides .env.local in production. Put your real secret in .env.prod.local (or a real environment variable / Symfony secret).
All options with their defaults:
buildwebproject_sylius_admin_two_factor:
enabled: true # turn the feature on or off (saved setups are kept)
required: false # every administrator must set up 2FA and cannot turn it off
issuer: null # name shown in the authenticator app (defaults to the request host)
backup_codes: 8 # number of one-time backup codes (4-20)
max_attempts: 5 # wrong codes allowed per administrator + IP...
lock_interval: '15 minutes' # ...within this interval before sign-out
admin_api: deny # refuse the password-only admin API token for 2FA users ("allow" not recommended)
admin_api_firewall: api_admin
encryption_key: '%kernel.secret%' # min. 16 characters; changing it makes saved setups unreadable
bin/console buildwebproject:admin-two-factor:reset [email protected]bin/console cache:pool:clear cache.rate_limiterFull documentation is in the README on GitHub.
Open source, MIT licensed. Developed by BuildWebProject.
No reviews yet. Be the first to review this product!
BuildWebProject is a Sylius e-commerce studio from Unjha, Gujarat, India. We build complete Sylius 2 stores you actually own, migrate shops from Shopify and WooCommerce, and develop production-tested Sylius plugins for the Indian market: Razorpay payments (UPI, cards, netbanking, wallets), admin two-factor authentication, smart cash-on-delivery with AI voice confirmation, Delhivery/Shiprocket shipping, WhatsApp Commerce with an AI assistant, GST invoicing, Zoho Books sync, POS and Meilisearch search. Our plugins run in production on Unjha Masala Mart (https://unjhamasalamart.com), a Sylius 2.3 / Symfony 7.4 store selling across India. Need a custom Sylius plugin or store? Contact us at https://buildwebproject.com
Read more© 2026 Sylius. All rights reserved.