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
| Stack | Concrete integration | Wins / loses; pick this if |
|---|---|---|
| Rails + webauthn-ruby | Configure allowed_origins and rp_id; use Credential.options_for_create, from_create(...).verify(challenge), and the corresponding get/assertion methods | Fits 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_webauthn | Use 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 verification | Fits existing Django users; loses if you omit session/CSRF integration. Pick this for an existing Django app. |
| FastAPI + py_webauthn | Use the same functions in API routes; implement a shared challenge store, session binding, credential persistence and session issuance explicitly | Fits 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