1. Go to this page and download the library: Download milpa/auth-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/ */
milpa / auth-webauthn example snippets
use Milpa\Auth\WebAuthn\Adapter\LbuchsWebAuthnVerifier;
use Milpa\Auth\WebAuthn\RelyingParty;
use Milpa\Auth\WebAuthn\WebAuthnAuthenticationContext;
// The relying party a ceremony runs for — resolved per request/tenant by the host's
// RelyingPartyResolver, never read from a single env-static value.
$rp = new RelyingParty(
id: 'crm.example',
name: 'Acme CRM',
allowedOrigins: ['https://crm.example'],
);
$verifier = new LbuchsWebAuthnVerifier($challengeStore, $credentialStore);
// 1. Begin: issue a single-use challenge, hand the browser its options.
$options = $verifier->createAuthenticationOptions($rp, new WebAuthnAuthenticationContext());
// $options->toArray() is the JSON body for navigator.credentials.get()
// 2. The browser runs the ceremony; the host relays the raw response back as a
// WebAuthnAuthenticationResponse (credentialId, clientDataJSON, authenticatorData,
// signature, userHandle) — none of this is verified yet.
// 3. Finish: verify the assertion fail-closed. This returns PROOF, never a session.
$result = $verifier->verifyAuthentication($response, $rp);
// The host — not this package — mints the trusted session from that proof:
$sessionStore->write(new Milpa\Auth\SessionRecord(
id: $newSessionId,
actorId: $result->actorId,
actorType: Milpa\Auth\ActorType::User,
createdAt: $now,
expiresAt: $now->modify('+8 hours'),
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.