Extensions
The following example is totally fictive. We will add an extension input loc=true to the request option object.
<?php
declare(strict_types=1);
use Webauthn\AuthenticationExtensions\AuthenticationExtension;
use Webauthn\AuthenticationExtensions\AuthenticationExtensionsClientInputs;
use Webauthn\PublicKeyCredentialRequestOptions;
// Extensions
$extensions = AuthenticationExtensionsClientInputs::create()
->add(AuthenticationExtension::create('loc', true))
;
// Public Key Credential Request Options
$publicKeyCredentialRequestOptions =
PublicKeyCredentialRequestOptions::create(
random_bytes(32) // Challenge
)
->setExtensions($extensions)
;Extension Output Checker
An Extension Output Checker will check the extension output.
It must implement the interface Webauthn\AuthenticationExtensions\ExtensionOutputChecker and throw an exception of type Webauthn\AuthenticationExtension\ExtensionOutputError in case of error.
In the previous example, we asked for the location of the device and we expect to receive geolocation data in the extension output.
Last updated
Was this helpful?