passkey-server 0.1.1

A generic, storage-agnostic Passkey (WebAuthn) server implementation.
Documentation
passkey-server-0.1.1 has been yanked.

Passkey

A storage-agnostic Rust implementation of the WebAuthn (Passkey) protocol.

Features

  • Generic Storage: Implement the PasskeyStore trait to use any database.
  • WASM Compatible: Optimized for WASM environments like Cloudflare Workers (use wasm feature).
  • Native Support: Fully compatible with multi-threaded runtimes like Tokio (enabled by default).
  • Easy Integration: Provides high-level handlers for registration and authentication.
  • Full Example: See examples/basic.rs for a complete Axum-based HTTP server implementation.

Installation

Add this to your Cargo.toml:

[dependencies]
# For native applications (Tokio, etc.)
passkey-server = "0.1.0"

# For Cloudflare Workers / WASM (non-Send)
passkey-server = { version = "0.1.0", default-features = false, features = ["wasm"] }

Quick Start

1. Implement PasskeyStore

use async_trait::async_trait;
use passkey_server::{PasskeyStore, Result};
use passkey_server::types::{StoredPasskey, PasskeyState};

struct MyDb;

#[async_trait(?Send)]
impl PasskeyStore for MyDb {
    async fn create_passkey(&self, user_id: i32, cred_id: &str, public_key: &str, name: &str, counter: i64, created_at: i64) -> Result<()> {

        // Save to DB
        Ok(())
    }
    // ... implement other methods
}

2. Registration Flow

use passkey_server::{PasskeyConfig, start_registration};

async fn handle_registration_start() {
    let config = PasskeyConfig {
        rp_id: "localhost".into(),
        rp_name: "Housou".into(),
        origin: "http://localhost:8787".into(),
    };
    let store = MyDb;
    let now = 1708358400000;

    let options = start_registration(&store, 1, "alice", "Alice", &config, now).await.unwrap();
    // Return options to frontend
}

Credits

Part of the Housou project.