chaitya / bio-metric-2fa-bundle
Symfony bundle for biometric 2FA using WebAuthn
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.3
- lbuchs/webauthn: ^2.1
- symfony/framework-bundle: ^6.3 || ^7.0
This package is auto-updated.
Last update: 2025-05-13 12:48:27 UTC
README
A Symfony bundle to enable secure biometric-based 2FA using WebAuthn (FIDO2).
Supports fingerprint, Face ID, and other platform authenticators across modern browsers.
π Features
- WebAuthn-based 2FA (FIDO2)
- Register multiple biometric devices per user
- Seamless post-login verification
- Easily toggle biometric 2FA per user
- Works with Symfony 6.3+ and 7.x
π¦ Installation
composer require vivan/biometric-2fa-bundle
Then enable the bundle (if using Symfony without Flex):
// config/bundles.php return [ Biometric2FABundle\Biometric2FABundle::class => ['all' => true], ];
βοΈ Configuration
Add this config file to your app:
# config/packages/biometric_2fa.yaml biometric_2fa: rp_id: "yourdomain.com" rp_name: "Your App Name" attestation_formats: ["packed", "fido-u2f"]
πΊοΈ Routes
Import all routes provided by the bundle:
# config/routes.yaml biometric_2fa: resource: '@Biometric2FABundle/Resources/config/routes.yaml'
π§© Setup in User Entity
Your User
class must implement the provided interface and use the trait:
use Biometric2FABundle\Security\BiometricUserInterface; use Biometric2FABundle\Security\BiometricUserTrait; class User implements BiometricUserInterface { use BiometricUserTrait; }
Then run a migration to add the biometric2FAEnabled
field.
π» WebAuthn UI
Register Device
Use the /biometric/register
route to let users register a new fingerprint device.
Authenticate
Once registered, users are redirected to /biometric/auth
for biometric login after entering credentials.
π Files Included
Entity/UserDevice
β stores WebAuthn credentialsHelper/UserDeviceHelper
β handles registration and verification logicBiometricController
β provides REST endpointsBiometricAuthSubscriber
β enforces post-login biometric check- Views and JS for:
biometrics_auth.html.twig
register_device.html.twig
settings.html.twig
π Security Flow
- User logs in (normal password)
- If biometric 2FA is enabled:
- Redirects to
/biometric/auth
- Verifies using browser credentials
- Access granted after success
- Redirects to
π Resources
- WebAuthn PHP Library: lbuchs/webauthn
- WebAuthn Guide: https://webauthn.guide
π License
MIT Β© Vivan β Free to use and modify.