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.110pydantic>=2.0open-passkey-server
Related Packages
open-passkey-- core WebAuthn verificationopen-passkey-server-- shared server logicopen-passkey-flask,open-passkey-django-- alternative 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_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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b97ba40b235250987523a045e05a10ed23b726282a62580e2da3dc9e17c6e53
|
|
| MD5 |
114c0da9ffdb36927d61ba3322aae1e4
|
|
| BLAKE2b-256 |
1b8cca73cc0402989f3896b4c0538289486b56a856eb4fc7fc86c948a70caae1
|
File details
Details for the file open_passkey_fastapi-0.1.4-py3-none-any.whl.
File metadata
- Download URL: open_passkey_fastapi-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.1 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 |
7e47c0d3e048c6f40b19672a30a18a0e1cd26638f4c8b3bd9b97f77167da5a56
|
|
| MD5 |
180e5097014a63ade652c18ec7e50257
|
|
| BLAKE2b-256 |
ae4a86cd6c610a4303868c1efb9f312d5e180099e0207514c3db0ffed7a11126
|