PHPackages                             ophelios/php-webauthn-passkey - 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. ophelios/php-webauthn-passkey

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

ophelios/php-webauthn-passkey
=============================

Simple WebAuthn library for PHP to ease passkey creation and authentication.

1.0.0(9mo ago)0371[1 issues](https://github.com/ophelios-studio/php-webauthn-passkey/issues)MITPHPPHP &gt;=8.4

Since Sep 23Pushed 5mo agoCompare

[ Source](https://github.com/ophelios-studio/php-webauthn-passkey)[ Packagist](https://packagist.org/packages/ophelios/php-webauthn-passkey)[ RSS](/packages/ophelios-php-webauthn-passkey/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

PHP WebAuthn Passkey
====================

[](#php-webauthn-passkey)

💿 Installation and dependencies
-------------------------------

[](#-installation-and-dependencies)

Install with Composer:

```
composer require ophelios/php-webauthn-passkey

```

Requirements: PHP &gt;= 8.4

### Add the required table into your database. The example below if for PostgreSQL:

[](#add-the-required-table-into-your-database-the-example-below-if-for-postgresql)

```
CREATE EXTENSION IF NOT EXISTS "pgcrypto";

CREATE TABLE account.passkeys
(
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id INT NOT NULL REFERENCES  ON DELETE CASCADE,
    credential_id BYTEA NOT NULL UNIQUE, -- raw credentialId (binary)
    public_key_cose BYTEA NOT NULL, -- COSE-encoded public key
    sign_count BIGINT NOT NULL DEFAULT 0,
    backup_eligible BOOLEAN NOT NULL DEFAULT false,
    prf_salt BYTEA, -- 32-byte per-passkey salt (used for deterministic PRF seed derivation)
    transports TEXT, -- e.g. "internal,usb,nfc"
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    last_used_at TIMESTAMPTZ
);

```

Replace the `` with the column name of your user identifier.

The identifier column if of type UUID given by `gen_random_uuid()` which is included in the extension `pgcrypto`. You can enable it with `CREATE EXTENSION IF NOT EXISTS "pgcrypto";` as shown above.

🌱 Usage
-------

[](#-usage)

### Create the broker instance

[](#create-the-broker-instance)

First, create the broker instance you will use to interact with the database.

```
