The Simplest Way to Make Azure Functions and Fido2 Work Like They Should
Pairing azure functions and fido2 lets serverless apps check hardware keys before running code. This setup replaces weak passwords with public key checks on every user login. Teams use this pair to build login endpoints that scale up on demand. The serverless app sends a random challenge, and the user key signs it. This workflow keeps secret keys on user devices and out of cloud databases. How azure functions and fido2 handle keys and data flow The login flow starts when a client app asks th
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 azure functions and fido2 lets serverless apps check hardware keys before running code. This setup replaces weak passwords with public key checks on every user login.
Teams use this pair to build login endpoints that scale up on demand. The serverless app sends a random challenge, and the user key signs it. This workflow keeps secret keys on user devices and out of cloud databases.
How azure functions and fido2 handle keys and data flow
The login flow starts when a client app asks the serverless endpoint to sign in. The function makes a unique string and saves it in fast storage for a moment. Since serverless instances spin up and down, local memory will not hold this state. Teams must link a shared store so any running instance can read the string.
Next, the browser passes that string to the hardware key or passkey on the device. The user touches the key, which signs the string along with the site domain name. The browser sends this signed response back to the serverless endpoint over HTTPS.
A second function reads the saved string and the user public key from a database. It checks the signature, the domain name, and the key counter value. If every check passes, the function issues a short session token for the app. The private key stays inside the user hardware token during the whole process.
Common failure modes and how to scope roles
Many teams fail by giving every serverless function one shared database account with broad rights. If an attacker finds a bug in one endpoint, they can rewrite public keys. That lets the attacker register a fake key and take over user accounts.
Split the sign-up and login logic into separate functions with distinct cloud roles. The login function only needs read rights on the public key table. The sign-up function needs write rights, but only after a strong identity check.
Azure RBAC + FIDO2 / WebAuthn: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Another common bug happens when teams skip domain checks during local tests and forget them. Always lock the Relying Party ID to the exact production domain name. Never let the function accept origin headers straight from the client request.
Unlogged database queries also create blind spots during security reviews. When a function reads or writes a public key, log the user ID and outcome. Mask sensitive fields like emails or phone numbers so logs stay safe for engineers. Keep network paths tight by placing the key database inside a private virtual network.
Managing state and key storage in production
Serverless functions time out fast if the database takes too long to answer. Keep the public key store close to the same cloud region as the functions. Store only the credential ID, public key bytes, sign count, and user reference.
Every time a user logs in, the hardware key raises its internal counter by one. The function must check that the new count is higher than the stored count. If the count drops or stays flat, someone may have cloned the hardware key. When that happens, the function should block the login and alert the security team.
Users also lose hardware keys or buy new laptops over time. Build a safe recovery flow that requires a second registered key or admin approval. Never fall back to simple text message codes on accounts protected by hardware keys.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Where should serverless apps store challenge strings during login?
Store challenge strings in a fast shared cache with a short expiration timer. Serverless instances do not share memory, so local variables will fail across requests. Delete the challenge string right after the login function checks it once.
Why do hardware key logins fail across different subdomains?
FIDO2 binds each public key to a specific Relying Party ID domain name. If the login function runs on a different domain, the browser blocks the check. Host the function under the main domain or set a shared parent domain.
How should teams handle cloned key counter alerts?
When a signature count is lower than the stored number, reject the login right away. Lock the specific credential ID in the database and write an alert to the log. Ask the user to verify their identity and register a fresh hardware key.
Related guides
In this post