Shared server logic for open-passkey WebAuthn/FIDO2 authentication
Project description
open-passkey-server
Framework-agnostic server logic for passkey authentication. Handles challenge generation, credential storage, ceremony orchestration, and optional stateless sessions. Used internally by the Flask, FastAPI, and Django bindings.
Install
pip install open-passkey-server
Usage
from open_passkey_server import PasskeyConfig, PasskeyHandler
from open_passkey_server import MemoryChallengeStore, MemoryCredentialStore
config = PasskeyConfig(
rp_id="example.com",
rp_display_name="Example",
origin="https://example.com",
challenge_store=MemoryChallengeStore(),
credential_store=MemoryCredentialStore(),
)
handler = PasskeyHandler(config)
# Registration
options = handler.begin_registration(user_id="user_123", username="alice")
# ... client performs navigator.credentials.create() ...
result = handler.finish_registration(user_id="user_123", credential={...})
# Authentication
options = handler.begin_authentication(user_id="user_123")
# ... client performs navigator.credentials.get() ...
result = handler.finish_authentication(user_id="user_123", credential={...})
API
PasskeyHandler(config: PasskeyConfig) -- main class with four methods:
begin_registration(user_id, username) -> dict-- returns WebAuthn creation optionsfinish_registration(user_id, credential, prf_supported=False) -> dict-- verifies and stores credentialbegin_authentication(user_id="") -> dict-- returns WebAuthn request options (discoverable if no user_id)finish_authentication(user_id, credential) -> dict-- verifies assertion, updates sign count
PasskeyConfig -- dataclass:
rp_id-- relying party domain (e.g."example.com")rp_display_name-- human-readable RP nameorigin-- expected origin (e.g."https://example.com")challenge_store-- implementsChallengeStore(default:MemoryChallengeStore)credential_store-- implementsCredentialStore(default:MemoryCredentialStore)session-- optionalSessionConfigfor stateless HMAC-SHA256 session cookies
Store Protocols
ChallengeStore(ABC) --store(key, challenge, timeout_seconds),consume(key) -> strCredentialStore(ABC) --store(cred),get(credential_id),get_by_user(user_id),update(cred),delete(credential_id)
Built-in implementations: MemoryChallengeStore, MemoryCredentialStore (thread-safe, in-memory, for development).
Session (opt-in)
from open_passkey_server.session import SessionConfig
config = PasskeyConfig(
rp_id="example.com",
rp_display_name="Example",
origin="https://example.com",
session=SessionConfig(secret="your-32+-character-hmac-secret"),
)
When configured, finish_registration and finish_authentication include a sessionToken in the result dict. Framework bindings set this as an HttpOnly cookie automatically.
Dependencies
open-passkey(core verification)
Testing
pytest tests/
Related Packages
open-passkey-- core WebAuthn verification (no HTTP)open-passkey-flask,open-passkey-fastapi,open-passkey-django-- framework bindings@open-passkey/sdk(npm) -- browser SDK
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file open_passkey_server-0.1.4.tar.gz.
File metadata
- Download URL: open_passkey_server-0.1.4.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea43f164d72aeeaec6fb733da998b27d5e367ab81a06ffad27370f8c2969ae0d
|
|
| MD5 |
95c3dddea08a4bc5ba16443745724ffe
|
|
| BLAKE2b-256 |
48345a6ce61c1141a8d8c323a57024671bd1eb4f025cbc0103fff5bc4ff6290f
|
File details
Details for the file open_passkey_server-0.1.4-py3-none-any.whl.
File metadata
- Download URL: open_passkey_server-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
062a88042f44fd4111f8d85abbcccd86aff25b09ef930ddac420407d1883c66c
|
|
| MD5 |
c2e0854db65934640e94619024dd1444
|
|
| BLAKE2b-256 |
a2297c71fe9432a2974bc0914193d1ad2a7c342dda8fc09f8a1dc010bb61c75c
|