The Simplest Way to Make Azure Functions and Webauthn Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair azure functions and webauthn to check hardware keys without running full servers. The browser signs a login challenge, and the cloud function checks that signature fast. This workflow removes shared passwords from your app login flow. Users tap a security key or use a phone sensor to log in. Your serverless code only stores a public key for each registered user. Attackers do not receive unmasked passwords from your database because no passwords exist there. How azure functions and

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.

Teams pair azure functions and webauthn to check hardware keys without running full servers. The browser signs a login challenge, and the cloud function checks that signature fast.

This workflow removes shared passwords from your app login flow. Users tap a security key or use a phone sensor to log in. Your serverless code only stores a public key for each registered user. Attackers do not receive unmasked passwords from your database because no passwords exist there.

How azure functions and webauthn handle user logins

The login flow starts when a user opens your web app. The browser asks an Azure Function to create a fresh random challenge. The function writes this challenge to fast storage with a short time limit. Then the function sends the challenge back to the browser.

Next, the browser passes the challenge to the local WebAuthn API. The user touches their hardware key or scans their fingerprint. The device signs the challenge with a private key that is masked in responses before reaching the hardware. The browser sends this signed response back to a second Azure Function.

That second function reads the stored challenge and the user public key. It checks that the domain name matches your real web app domain. It also checks the cryptographic signature against the stored public key. If the check passes, the function returns a session token to the user.

Common failure modes and how to scope permissions

Many teams make mistakes when they set up state for serverless logins. Azure Functions run without local memory between separate web requests. If you save the login challenge in local memory, the next request will fail. A second function instance will not find the challenge created by the first one. You must store challenges in a shared database with a strict expiration rule.

Broad database roles create another big risk for your serverless backend. Teams often give every function full read and write permissions to user tables. If one function has a bug, an attacker can overwrite stored public keys. You should split registration functions from login check functions. Give the login function read-only permissions to the public key table.

Azure RBAC + FIDO2 / WebAuthn: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged database queries also hurt your security posture during an audit. When five functions share one database account, logs show only that single account. You cannot tell which function changed a user key or read sensitive data. Masking rules can also rewrite emails, phone numbers, card numbers, and national IDs in results.

Network rules and origin checks for serverless keys

WebAuthn relies on strict origin checks to block phishing sites. The browser binds every key to a specific domain name during registration. Your Azure Function must check this origin string on every single login call. Never turn off origin checks in production to fix local test errors. Instead, pass the expected domain through a locked app setting for each stage.

You should also lock down network paths between your functions and data stores. Place your storage tables inside a private virtual network. Allow traffic only from the specific functions that handle login and registration requests. This stops outside callers from reading challenges or tampering with stored public keys.

Keep your signature counters updated when hardware keys support them. Each time a hardware key signs a challenge, it raises an internal number. Your function should compare this new number against the last saved number. If the new number is lower, someone may have cloned the hardware key. Your function can then block the login and alert your security team.

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 Azure Functions store WebAuthn challenges between requests?

Store challenges in a fast shared database with automatic expiration turned on. Delete each challenge right after the check function reads it once. This stops attackers from replaying old login requests.

What happens if a user loses their registered hardware key?

Let users register at least two hardware keys during initial account setup. If they lose their main key, they can log in with the backup key. Never fall back to a plain password recovery link.

How do we stop functions from having too much database power?

Give each function its own managed identity with narrow database roles. The login check function only needs to read public keys and update counters. Only the registration function should add new key rows.

The query runs. The emails stay hidden.