The Simplest Way to Make Firestore and Webauthn Work Like They Should
Pairing firestore and webauthn lets your app check hardware keys and store public records in a cloud database. This setup replaces weak passwords with fast biometric logins backed by scalable document collections. Modern teams want strong login flows without running complex servers. WebAuthn handles the browser key checks on the user device. Firestore stores the public key data and user profile records. When you link them well, users log in with a touch or face scan. Your backend reads the stor
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Pairing firestore and webauthn lets your app check hardware keys and store public records in a cloud database. This setup replaces weak passwords with fast biometric logins backed by scalable document collections.
Modern teams want strong login flows without running complex servers. WebAuthn handles the browser key checks on the user device. Firestore stores the public key data and user profile records. When you link them well, users log in with a touch or face scan. Your backend reads the stored key and grants a session token right away.
How login and data flow between firestore and webauthn
WebAuthn does not need a database on its own, and Firestore does not verify browser hardware keys natively. You need a small backend service to join the two tools together. First, the user asks to register a new passkey or hardware token. Your backend creates a random string challenge and saves it in a short-lived Firestore document.
Next, the browser prompts the user to touch their key or scan their face. The device signs the challenge and sends the response back to your server. Your server checks the signature against the temporary challenge stored in the database. If the check passes, the server deletes the challenge and writes the new public key to the user collection.
Future logins follow a very similar path. The server writes a fresh login challenge to the database and sends it to the browser. The user signs it with their device, and the server reads the stored public key from Firestore to verify it. Once verified, your server mints a custom identity token so the client app can read allowed documents.
Common failure modes and how to scope roles
Many teams make mistakes when they set up database permissions for login flows. A common flaw is letting client browsers read or write public key documents directly. If a user can edit their own key collection from the browser, they can bypass the hardware check. Client rules must block all direct writes to key and challenge collections.
Shared service accounts cause another big risk for engineering teams. Teams often give the login backend a broad admin role that can read every collection. If an attacker finds a bug in your login server, they can dump your whole database. Instead, give the login service a tight role that only touches the key and challenge records.
FIDO2 / WebAuthn + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged database queries also hurt teams during security audits. When engineers debug broken passkeys, they often log in with shared admin keys to check user documents. These manual reads rarely tie back to an individual engineer identity. You should require individual logins for team members and mask sensitive fields like emails or phone numbers in query results.
Keeping challenge records clean and secure
Stale login challenges can pile up fast in your document collections. If an attacker grabs an old challenge, they might try a replay attack against your server. Every challenge document needs a strict expiration time stamp set by the server. Your backend must check this time stamp before it checks the cryptographic signature.
You should also set up automatic deletion rules for expired challenge records. Removing old records keeps your storage costs low and shrinks your attack surface. Also, track sign-in counters inside each user public key document. If a hardware token counter goes backward, your server knows someone cloned the key and can block the account.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can the browser verify WebAuthn signatures directly with Firestore rules?
No, database security rules cannot check cryptographic hardware signatures on their own. You must use a backend server or cloud function to verify the signature and issue a session token.
What WebAuthn data should we store in the user document?
Store the credential ID, the public key bytes, and the signature counter in a dedicated subcollection. Never store private keys, and block client apps from editing these records directly.
How do we handle engineers reading user key records during support tickets?
Remove shared admin keys and require engineers to use their own identity for database reads. Apply data masking to rewrite emails and phone numbers in the returned document fields.
Related guides
In this post