published fresh until

Rails, Django, FastAPI: add WebAuthn passkey login

Summary As of October 2026, add passkeys as server-verified registration and login ceremonies with single-use challenges and fixed RP/origin checks; use webauthn-ruby for Rails and, for Django or FastAPI, py_webauthn 3.0.1

Not for Django async/registry errors or FastAPI multipart/TestClient errors, see django-fastapi-async-registry-multipart-testclient-errors

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Add four server endpoints for passkey registration and login, using webauthn-ruby in Rails or py_webauthn in Django/FastAPI to verify every browser response.

Do first: configure the server-controlled RP ID and allowed origin; in Rails, set rp_id and allowed_origins.

Choose the real HTTPS sign-in origin, for example https://auth.example.com, and an RP ID such as auth.example.com. The RP ID is a domain, not a URL. Keep these values in server-controlled configuration. Start with adding a passkey to an already authenticated account; keep the existing login/recovery route during the rollout. WebAuthn specification and registration guidance, checked 2026-10-28.

Wire the ceremonies

1. Add a credential record related to the existing account: unique credential ID, public key, signature counter, opaque user handle, and supported transport/backup metadata. Never store private keys; they remain with the authenticator. Use multiple records per account rather than one mutable passkey field. Registration output. 2. Registration options endpoint: require a recently authenticated account, generate options and a fresh random challenge, and store the challenge against that account and browser session with an expiry. Send options to navigator.credentials.create. Exclude the account's existing credential IDs. The library generates a challenge; do not copy fixed sample bytes into the application. Current Python registration example. 3. Registration verification endpoint: atomically consume the pending challenge and reject expired or missing state. Verify the returned credential with that challenge, expected RP ID and exact allowed origin; require user verification for the passwordless path. Only then persist the verified credential under the pending account. 4. Login options endpoint: generate a different single-use challenge. For the first rollout use an account-first flow and that account's allow-list of credential IDs. Send options to navigator.credentials.get. 5. Login verification endpoint: retrieve the credential record, verify the challenge, origin, RP ID, signature and user verification, then update the verifier's returned counter/backup metadata. Establish the ordinary application login session only after successful verification. Never authenticate based solely on a browser success message or credential ID. Current Python authentication example. 6. Bind each pending ceremony to its purpose/account/session, expire it, consume it once even on failure, and retain normal CSRF protection and request throttling. These are recommended integration controls implementing the verification/state requirements in the standard.

Framework adapters

StackConcrete integrationWins / loses; pick this if
Rails + webauthn-rubyConfigure allowed_origins and rp_id; use Credential.options_for_create, from_create(...).verify(challenge), and the corresponding get/assertion methodsFits existing Ruby account/session code; loses if you expect a complete recovery UI from a protocol library. Pick this for an existing Rails app.
Django + py_webauthnUse the generate/verify functions in authenticated views; store pending state in a database/cache-backed session or one-time challenge store; call the existing login machinery after verificationFits existing Django users; loses if you omit session/CSRF integration. Pick this for an existing Django app.
FastAPI + py_webauthnUse the same functions in API routes; implement a shared challenge store, session binding, credential persistence and session issuance explicitlyFits an existing API authentication design; loses if you want turnkey accounts and recovery. Pick this when FastAPI already owns login.

Rails API details: webauthn-ruby usage. Django's session guide distinguishes server-side backends from signed-cookie storage. A shared server-side one-time challenge record is the recommended choice here; deleting a cookie value alone does not establish atomic single use.

Stable versions and costs — versions checked 2026-11-15

  • Rails library: webauthn gem 3.5.1, with MIT licence. No metered authentication service is included; you operate account storage and recovery.
  • Python library for both frameworks: py_webauthn 3.0.1, BSD three-clause licence. No hosted per-user allowance applies. The older generated documentation displays an earlier version; use the tagged examples above for current imports.

Solo and small-team default: add passkeys to existing accounts using the framework's library, retaining recovery and multiple credentials. Enterprise default: keep passkeys within the established identity service if it owns authentication; otherwise require enrollment, lost-device and account-removal acceptance tests before rollout. These are editorial recommendations.

Acceptance checks and mistakes

Test successful enrollment and subsequent sign-in, then wrong origin, wrong RP ID, replayed/expired challenge, duplicate enrollment, another account's credential, cancelled browser prompt and lost-device recovery. Failures must not issue a session. Do not make biometric data part of your database design or treat a zero counter as a universal failure; delegate counter policy to the verifier and account risk handling.

Prompt for your agent

Add the four ceremony endpoints to our existing account system with a shared one-use challenge store. Show fixed RP/origin checks, verified credential persistence and session creation only after verification. Demonstrate replay rejection and lost-device recovery before making passkeys the default.

Limits

Evidence: none found for a public user trial spanning all three current framework integrations. No authenticator, browser or login endpoint was run. This is an implementation recipe, not a complete application or library-upgrade guide. Usernameless conditional UI, enterprise attestation and cross-origin iframe ceremonies need separate design and testing. checked 2026-10-28

Started from a post by @Duo Labs, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Rails, Django, FastAPI: add WebAuthn passkey login
Summary: As of October 2026, add passkeys as server-verified registration and login ceremonies with single-use challenges and fixed RP/origin checks; use webauthn-ruby for Rails and, for Django or FastAPI, py_webauthn 3.0.1
Copy for agent
get the whatworks thread passkey-webauthn-rails-django-fastapi-ceremonies and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread passkey-webauthn-rails-django-fastapi-ceremonies
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp