Meet Solenne
The new B2C distribution for Sylius
Explore demo
No reviews yet

Admin Two-Factor Authentication (2FA, TOTP)

Product Admin Two-Factor Authentication (2FA, TOTP) Image

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.

Published
16.11.2026
Latest version
v1.0.0
Last update
16.11.2026
Sylius version
2.0 - 2.3
Downloads
< 1K

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.

Features

  • Works with every authenticator app: Google Authenticator, Microsoft Authenticator, 1Password, Authy, Bitwarden and others (RFC 6238 TOTP, 6 digits, 30 seconds).
  • QR code generated on your server (SVG), so the secret is never sent to a third-party image service.
  • One-time backup codes (8 by default), shown once with a download button and replaceable at any time.
  • Replay protection: each authenticator code works only once, even inside its 30-second window.
  • Lockout: too many wrong codes (5 per administrator and IP within 15 minutes by default) sign the session out.
  • Optional enforcement: make every administrator set up 2FA at their next page and block turning it off.
  • Admin API protection: the password-only Sylius admin API token is refused for administrators who use (or must use) 2FA, so the API cannot bypass the second factor.
  • Encrypted at rest: secrets encrypted with libsodium (XSalsa20-Poly1305), backup codes stored only as keyed HMAC-SHA256 hashes.
  • Native Sylius 2 admin UI: Tabler design, Twig Hooks, translations and a shield icon in the admin navbar.
  • No changes to your entities: setups live in a separate table linked to sylius_admin_user.
  • Recovery command for an administrator who lost both phone and backup codes.

Requirements

  • PHP 8.2+ with ext-sodium
  • Sylius 2.x (tested on 2.3.2)
  • Symfony 6.4 or 7.x
  • MySQL / MariaDB (migration included)

Installation

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).

Configuration

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

Lost access

  • Lost phone: sign in with a backup code, then turn two-factor off and on again (or create new backup codes).
  • Lost phone and backup codes: remove the setup on the server with bin/console buildwebproject:admin-two-factor:reset [email protected]
  • Locked out after wrong codes: wait for lock_interval, or run bin/console cache:pool:clear cache.rate_limiter

Full documentation is in the README on GitHub.

Open source, MIT licensed. Developed by BuildWebProject.

Reviews

No reviews yet

No reviews yet. Be the first to review this product!

Loading
  • MIT license
  • Free updates
  • Community support

Have already account? Sign in
See how it works
Compatibility & requirements
  • Compatible with Sylius 2.0 and higher
  • PHP 8.2 or newer with ext-sodium
  • Symfony 6.4 or 7.x
  • MySQL / MariaDB (migration included)
  • APP_SECRET of at least 16 characters

No reviews yet
2 plugins
Since 16.11.2026

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
Sylius Addons Marketplace

Discover plugins, themes, and resources from trusted vendors, helping you get the most out of your work.

© 2026 Sylius. All rights reserved.

Powered by Stripe