PHPackages                             rawilk/yubikey-u2f - 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. rawilk/yubikey-u2f

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

rawilk/yubikey-u2f
==================

Add Yubikey U2F authentication to Laravel.

v1.0.1(3y ago)1330MITPHPPHP ^8.1

Since May 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rawilk/yubikey-u2f)[ Packagist](https://packagist.org/packages/rawilk/yubikey-u2f)[ Docs](https://github.com/rawilk/yubikey-u2f)[ GitHub Sponsors](https://github.com/rawilk)[ RSS](/packages/rawilk-yubikey-u2f/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

Yubikey U2F
===========

[](#yubikey-u2f)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9204c033b9e0bd6bfc6417adf495fded1f115d9561e9d4cc52ca79cb268716c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726177696c6b2f797562696b65792d7532662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rawilk/yubikey-u2f)[![Tests](https://github.com/rawilk/yubikey-u2f/workflows/Tests/badge.svg?style=flat-square)](https://github.com/rawilk/yubikey-u2f/workflows/Tests/badge.svg?style=flat-square)[![Total Downloads](https://camo.githubusercontent.com/3066f02a1f13020519f92da8f3d590b0c89b3acfeb7c1d7c4055a809ff697470/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726177696c6b2f797562696b65792d7532662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rawilk/yubikey-u2f)

[![social image](https://camo.githubusercontent.com/89766a272ea72618d602502e57124f8f696a3266020ca304825a303c43c0aba8/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f797562696b65792d7532662e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d726177696c6b253246797562696b65792d753266267061747465726e3d7061726b6179466c6f6f72267374796c653d7374796c655f31266465736372697074696f6e3d4164642b597562696b65792b5532462b61757468656e7469636174696f6e2b746f2b4c61726176656c2e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d66696e6765722d7072696e74)](https://camo.githubusercontent.com/89766a272ea72618d602502e57124f8f696a3266020ca304825a303c43c0aba8/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f797562696b65792d7532662e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d726177696c6b253246797562696b65792d753266267061747465726e3d7061726b6179466c6f6f72267374796c653d7374796c655f31266465736372697074696f6e3d4164642b597562696b65792b5532462b61757468656e7469636174696f6e2b746f2b4c61726176656c2e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d66696e6765722d7072696e74)

**Important Note:** This package is not a webauthn package. This will only work using the OTP codes that are generated from the YubiKey device. This was also mostly just a learning package for me, and probably shouldn't actually be used in production. If you want to support security keys and other devices, consider using webauthn instead.

If you have a YubiKey from [Yubico](https://yubico.com), you can add two-factor support for a security key to your Laravel applications. Your user accounts will be able to register up to 5 security keys (configurable) to their account, and then use those keys as a form of two-factor authentication for your application.

**Note:** This package only provides the backend code necessary for verifying and associating keys with users. You will need to make the UI necessary for this and also add the logic to your authentication workflows for two-factor authentication.

### Requirements:

[](#requirements)

- [Buy a YubiKey](https://www.yubico.com/store/)
- [Generate an API Key](https://upgrade.yubico.com/getapikey/)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require rawilk/yubikey-u2f
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="yubikey-u2f-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="yubikey-u2f-config"
```

You can view the default configuration here:

You can publish the language files provided by this package with:

```
php artisan vendor:publish --tag="yubikey-u2f-translations"
```

Usage
-----

[](#usage)

First, add the `\Rawilk\Yubikey\Models\HasYubikeys` trait to your user model. Then you can verify/associate a key for a user like this:

```
// An exception will be thrown if the key is not valid.
$response = \Rawilk\Yubikey\Facades\Yubikey::verify(request()->otp);

Auth::user()->associateYubikeyIdentity($response['identity']);

// On a login 2fa request, you can verify the key is valid and tied to the user like this:
$user->verifyYubikeyIdentity(request()->otp);
```

**Note:** `request()->otp` is just an example of retrieving the input sent to the server containing the security key signature that is generated when touching the security key. Make sure to adjust accordingly depending on how you capture that.

Documentation
-------------

[](#documentation)

For more documentation, please visit:

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security
--------

[](#security)

Please review [my security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Randall Wilk](https://github.com/rawilk)
- [All Contributors](../../contributors)

Inspiration for this package comes from:

- [marcinkozak/yubikey](https://github.com/MarcinKozak/Yubikey)
- [Yubico/php-yubico](https://github.com/Yubico/php-yubico)

Alternatives
------------

[](#alternatives)

I've created this package since any existing solutions are either archived or not actively maintained anymore. If you have an alternative to this package, please feel free to PR an update the README with your package on it.

- [marcinkozak/yubikey](https://github.com/MarcinKozak/Yubikey)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

2

Last Release

1458d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e2f599d4d290bbb514a933d4f21c3f18fb093f5f8a9994cb17f5469853c749c?d=identicon)[rawilk](/maintainers/rawilk)

---

Top Contributors

[![rawilk](https://avatars.githubusercontent.com/u/22842525?v=4)](https://github.com/rawilk "rawilk (54 commits)")

---

Tags

2fau2fyubicoyubikeylaravel2fayubikeyrawilkyubicou2f

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rawilk-yubikey-u2f/health.svg)

```
[![Health](https://phpackages.com/badges/rawilk-yubikey-u2f/health.svg)](https://phpackages.com/packages/rawilk-yubikey-u2f)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M52](/packages/php-open-source-saver-jwt-auth)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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