Skip to main content

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 options
  • finish_registration(user_id, credential, prf_supported=False) -> dict -- verifies and stores credential
  • begin_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 name
  • origin -- expected origin (e.g. "https://example.com")
  • challenge_store -- implements ChallengeStore (default: MemoryChallengeStore)
  • credential_store -- implements CredentialStore (default: MemoryCredentialStore)
  • session -- optional SessionConfig for stateless HMAC-SHA256 session cookies

Store Protocols

  • ChallengeStore (ABC) -- store(key, challenge, timeout_seconds), consume(key) -> str
  • CredentialStore (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_passkey_server-0.1.4.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_passkey_server-0.1.4-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for open_passkey_server-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ea43f164d72aeeaec6fb733da998b27d5e367ab81a06ffad27370f8c2969ae0d
MD5 95c3dddea08a4bc5ba16443745724ffe
BLAKE2b-256 48345a6ce61c1141a8d8c323a57024671bd1eb4f025cbc0103fff5bc4ff6290f

See more details on using hashes here.

File details

Details for the file open_passkey_server-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for open_passkey_server-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 062a88042f44fd4111f8d85abbcccd86aff25b09ef930ddac420407d1883c66c
MD5 c2e0854db65934640e94619024dd1444
BLAKE2b-256 a2297c71fe9432a2974bc0914193d1ad2a7c342dda8fc09f8a1dc010bb61c75c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page