PHPackages                             patel/biometric-2fa-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. patel/biometric-2fa-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

patel/biometric-2fa-bundle
==========================

Symfony bundle for biometric 2FA using WebAuthn

v1.0.0(1y ago)014MITPHPPHP ^8.3

Since May 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/niravpateljoin/biometric-2fa-bundle)[ Packagist](https://packagist.org/packages/patel/biometric-2fa-bundle)[ RSS](/packages/patel-biometric-2fa-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

patel/biometric-2fa-bundle
==========================

[](#patelbiometric-2fa-bundle)

> Symfony bundle for biometric 2FA using WebAuthn

`patel/biometric-2fa-bundle` is a Symfony bundle that enables biometric two-factor authentication (2FA) using WebAuthn with support for customizable user device storage, redirect paths, and logout integration.

---

🚀 Installation
--------------

[](#-installation)

```
composer require patel/biometric-2fa-bundle
```

Then enable the bundle in `config/bundles.php` (if not auto-loaded):

```
return [
    Biometric2FA\Biometric2FABundle\Biometric2FABundle::class => ['all' => true],
];
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Create a config file:

```
# config/packages/biometric_2fa.yaml
biometric_2fa:
  rp_id: "localhost"
  rp_name: "Test App"
  device_entity: 'App\Entity\UserDevice'
  redirect_path: 'app_dashboard'
  logout_path: 'app_logout'
```

add this in doctrine.yaml

```
types:
    blob_string: Biometric2FA\Doctrine\DBAL\Types\BlobStringType
```

load bundle routes, (config/routes.yaml)

```
biometric_2fa:
    resource: '@Biometric2FABundle/Resources/config/routes.yaml'
```

add this in service.yaml, This line tells Symfony that whenever a service (like a controller or helper) needs the UserDeviceRepositoryInterface, it should use your actual UserDeviceRepository class.

Without it, Symfony cannot auto-wire the interface because interfaces can’t be instantiated, and you haven’t told Symfony which class to use.

```
Biometric2FA\Repository\UserDeviceRepositoryInterface: '@App\Repository\UserDeviceRepository'
```

🧩 Database Setup
----------------

[](#-database-setup)

Your app must implement a concrete `UserDevice` entity that extends the bundle's abstract class, and map User entity with it, so we can store user devices.

```
use Biometric2FA\Entity\UserDevice as BaseDevice;

class UserDevice extends BaseDevice
{
    #[ORM\ManyToOne(targetEntity: User::class)]
    #[ORM\JoinColumn(nullable: false)]
    private BiometricUserInterface $user;

    public function getUser(): BiometricUserInterface
    {
        return $this->user;
    }

    public function setUser(BiometricUserInterface $user): static
    {
        $this->user = $user;

        return $this;
    }
}
```

And a repository class that implements:

```
use Biometric2FA\Repository\UserDeviceRepositoryInterface;

class UserDeviceRepository extends ServiceEntityRepository implements UserDeviceRepositoryInterface
{
    public function getCredentialsForUser(UserInterface $user): array
    {
        return $this->createQueryBuilder('d')
            ->select('d.credentialId')
            ->where('d.user = :user')
            ->setParameter('user', $user)
            ->getQuery()
            ->getSingleColumnResult();
    }
}
```

---

🧠 User Interface Requirements
-----------------------------

[](#-user-interface-requirements)

Your User entity should implement:

```
use Biometric2FA\Security\BiometricUserInterface;

class User implements BiometricUserInterface
{
    private bool $enableBioMetricsFor2fa = false;

    public function isBiometric2FAEnabled(): bool
    {
        return $this->enableBioMetricsFor2fa;
    }

    public function setBiometric2FAEnabled(bool $enabled): void
    {
        $this->enableBioMetricsFor2fa = $enabled;
    }
}
```

---

🛡️ Routes
---------

[](#️-routes)

The bundle exposes the following biometric routes (protected):

Route NamePathPurpose`app_biometric_auth``/biometric/auth`Biometric login UI`bio_metrics_get_args``/biometric/get-args`Generate WebAuthn challenge args`bio_metrics_create_args``/biometric/create-args`Setup credentials challenge args`bio_metrics_process_create``/biometric/process-create`Save credential`bio_metrics_verify``/biometric/verify`Verify login assertion`bio_metrics_bio_metrics_settings``/biometric/settings`For enable/disable biometric---

✨ Usage in Twig
---------------

[](#-usage-in-twig)

**Biometric Settings UI:**

```
Logout
```

---

📦 Features
----------

[](#-features)

- WebAuthn support for biometric authentication
- Device registration and secure verification
- Customizable redirect/logout path via config
- Event subscriber to enforce biometric check post-login

---

🧪 Testing
---------

[](#-testing)

Ensure you call:

```
php bin/console doctrine:schema:update --force
```

Register your fingerprint and enable biometric login from the settings page.

---

📄 License
---------

[](#-license)

This bundle is released under the MIT License.

🔐 Biometric Authentication Flow
-------------------------------

[](#-biometric-authentication-flow)

[![Biometric Auth](docs/biometric-auth.png)](docs/biometric-auth.png)This screen prompts the user to authenticate using a biometric method such as fingerprint or Face ID. It appears automatically when biometric 2FA is required after login.

⚙️ Settings Page
----------------

[](#️-settings-page)

[![Settings](docs/settings-page.png)](docs/settings-page.png)This page allows users to enable or disable biometric authentication for their account. Changes are saved securely and reflected immediately in the login flow.

---

✨ Template Override Guide
-------------------------

[](#-template-override-guide)

You can fully override the default templates provided by the bundle while keeping the JavaScript functionality working.

### ✅ Required Steps

[](#-required-steps)

1. **Include the JS files** in your custom layout:

```

```

2. **Use the following `data-*` attributes** in your HTML to ensure JavaScript works correctly:

PurposeRequired AttributeBiometric Auth Button`data-biometric-auth`Settings Form`data-biometric-settings-form`### ✅ Example Override for Authentication Page

[](#-example-override-for-authentication-page)

```
{% extends '@Biometric2FA/layout.html.twig' %}

{% block biometric_auth_content %}
    Authenticate
{% endblock %}
```

### ✅ Example Override for Settings Page

[](#-example-override-for-settings-page)

```
{% extends '@Biometric2FA/layout.html.twig' %}

{% block biometric_auth_content %}

        ...

{% endblock %}
```

### ✅ Flash Message Rendering (included in layout)

[](#-flash-message-rendering-included-in-layout)

The layout automatically renders flash messages on page reload using Symfony's `FlashBag`.

---

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance46

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

411d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27916009?v=4)[Patel](/maintainers/niravpateljoin)[@niravpateljoin](https://github.com/niravpateljoin)

---

Top Contributors

[![niravpateljoin](https://avatars.githubusercontent.com/u/27916009?v=4)](https://github.com/niravpateljoin "niravpateljoin (2 commits)")

### Embed Badge

![Health badge](/badges/patel-biometric-2fa-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/patel-biometric-2fa-bundle/health.svg)](https://phpackages.com/packages/patel-biometric-2fa-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[shopware/storefront

Storefront for Shopware

684.6M235](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
