Skip to main content

FastAPI router for open-passkey WebAuthn/FIDO2 authentication

Project description

open-passkey-fastapi

FastAPI router for passkey (WebAuthn/FIDO2) authentication. Thin wrapper around open-passkey-server -- registers async routes with Pydantic request validation.

Install

pip install open-passkey-fastapi

Quick Start

from fastapi import FastAPI
from open_passkey_fastapi import (
    create_passkey_router,
    PasskeyConfig,
    MemoryChallengeStore,
    MemoryCredentialStore,
)

app = FastAPI()

passkey_router = create_passkey_router(PasskeyConfig(
    rp_id="localhost",
    rp_display_name="My App",
    origin="http://localhost:8000",
    challenge_store=MemoryChallengeStore(),
    credential_store=MemoryCredentialStore(),
))

app.include_router(passkey_router, prefix="/passkey")

With Sessions

from open_passkey_server.session import SessionConfig

passkey_router = create_passkey_router(PasskeyConfig(
    rp_id="example.com",
    rp_display_name="Example",
    origin="https://example.com",
    session=SessionConfig(secret="your-32+-character-hmac-secret"),
))

When session is configured, two additional routes are registered and login/register responses set an HttpOnly session cookie automatically.

Routes

Method Path Description
POST /register/begin Start registration ceremony
POST /register/finish Complete registration
POST /login/begin Start authentication ceremony
POST /login/finish Complete authentication
GET /session Validate session cookie (session config required)
POST /logout Clear session cookie (session config required)

API

create_passkey_router(config: PasskeyConfig) -> APIRouter

Returns a FastAPI APIRouter with the routes above. All route handlers are async. Request bodies are validated with Pydantic models.

Dependencies

  • fastapi>=0.110
  • pydantic>=2.0
  • open-passkey-server

Related Packages

  • open-passkey -- core WebAuthn verification
  • open-passkey-server -- shared server logic
  • open-passkey-flask, open-passkey-django -- alternative 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_fastapi-0.1.4.tar.gz (3.5 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_fastapi-0.1.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file open_passkey_fastapi-0.1.4.tar.gz.

File metadata

  • Download URL: open_passkey_fastapi-0.1.4.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for open_passkey_fastapi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3b97ba40b235250987523a045e05a10ed23b726282a62580e2da3dc9e17c6e53
MD5 114c0da9ffdb36927d61ba3322aae1e4
BLAKE2b-256 1b8cca73cc0402989f3896b4c0538289486b56a856eb4fc7fc86c948a70caae1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_passkey_fastapi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e47c0d3e048c6f40b19672a30a18a0e1cd26638f4c8b3bd9b97f77167da5a56
MD5 180e5097014a63ade652c18ec7e50257
BLAKE2b-256 ae4a86cd6c610a4303868c1efb9f312d5e180099e0207514c3db0ffed7a11126

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