# passkey-rs

> WebAuthn / passkey relying-party library for Rust (0.2).

- Author: Yaroslav Koval (https://koval-dev.org/)
- Source: https://github.com/koval01/passkey-rs
- Clone: git clone https://github.com/koval01/passkey-rs.git
- Language: Rust
- Last updated: 2026-08-09

## README (excerpt)

# passkey-rs

WebAuthn / passkey **relying-party** library for Rust (`0.2`).

**Pure Rust crypto** (`p256`, `sha2`, `ciborium`, `x509-parser`) — no OpenSSL / C in this crate. No dependency on `webauthn-rs`.

Finance-strict defaults: `__Host-` cookies, SameSite=Strict, UV locked Required, 5m/1h sessions, IP-bound ceremonies/sessions, named login only, lockout + rate limits, closed self-registration. See [SECURITY.md](SECURITY.md).

Demo console (JSON + Guide glossary): sibling repo [`rust-axum-passkey`](../rust-axum-passkey).

## Scope

- ES256 (COSE `-7`) on NIST P-256; optional Ed25519 / EdDSA (COSE `-8`) via `offer_ed25519` (default **true**)
- Attestation **`none` + `packed`** (self / basic), configurable [`AttestationPolicy`](src/config.rs) (default: ask `direct`, accept none+packed)
- Default **`userVerification: required`** (enforced; locked unless `allow_relaxed_uv`)
- Async stores: `UserStore`, `ChallengeStore`, `SessionStore`, `RateLimitStore`
- Optional Redis adapters (challenges, sessions, rate limits)
- Optional Postgres `UserStore` (`feature = "postgres"`, sqlx + rustls)
- Opaque client errors, CAS sign counts, session-gated add-credential

## Axum quick start

```rust
use passkey_rs::{CookieConfig, PasskeyConfig, RelyingParty, UserVerificationPolicy};
use passkey_rs::axum::{PasskeyState, router};

let rp = RelyingParty::new("example.com", "My App", "https://example.com");
let config = PasskeyConfig::new()
    .user_verification(UserVerificationPolicy::Required)
    .cookies(CookieConfig::new());
let api = router(PasskeyState::with_config(rp, config));
```

Attestation presets: `AttestationPolicy::compatible()`, `none_only()`, `require_packed()`, `require_trusted_packed(anchors)`.

## Production checklist

- [ ] Durable `UserStore` — `PostgresUserStore` (`feature = "postgres"`) or your SQL with **atomic** CAS
- [ ] Redis for challenges + sessions (`feature = "redis"`, Redis ≥ 6.2 for `GETDEL`)
- [ ] HTTPS termination; cookie `Secure=true` (`__Host-` requires it)
- [ ] `trust_forwarded_headers` only behind a trusted proxy
- [ ] Leave `allow_open_registration=false` unless product needs public signup
- [ ] Review rate-limit knobs; ship audit logs (`audit=true` tracing)
- [ ] Do **not** lower UV to `Preferred` for high-value flows without a risk engine

## Multi-instance

| Data | Backend |
|------|---------|
| Users + credentials | `PostgresUserStore` (or your SQL) |
| Challenges | `RedisChallengeStore` |
| Sessions | `RedisSessionStore` |

[... continued on GitHub]
