PHP code example of rawilk / yubikey-u2f

1. Go to this page and download the library: Download rawilk/yubikey-u2f library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rawilk / yubikey-u2f example snippets


// 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);
bash
php artisan vendor:publish --tag="yubikey-u2f-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="yubikey-u2f-config"
bash
php artisan vendor:publish --tag="yubikey-u2f-translations"