PHP code example of phpdot / webauthn

1. Go to this page and download the library: Download phpdot/webauthn 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/ */

    

phpdot / webauthn example snippets


$optionsJson = $webauthn->beginRegistration($user);       // → publicKey.create options (user = WebauthnUser)
$recordJson  = $webauthn->finishRegistration($user, $json);  // validates, refuses duplicates, persists

$optionsJson = $webauthn->beginAuthentication($user->handle);  // → publicKey.get options
$handle      = $webauthn->finishAuthentication($json);          // validates, saves the counter, answers the handle

$engine = new AuthenticationEngine(
    [new PasswordStage(...), new WebauthnStage($webauthn, $identityProvider)],
    $policy,
    $store,
);