The Simplest Way to Make Fastly Compute Edge and Keycloak Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair Fastly Compute Edge and Keycloak to check user logins close to your users. This setup lets Keycloak issue tokens while edge workers verify them before traffic hits your backend. Teams use this pattern to block bad requests early in the network path. Your origin servers stay safe from bad traffic and spend less time checking user keys. How Fastly Compute Edge and Keycloak share user data Keycloak acts as your main login server and holds all user accounts and group roles. When a user

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.

You pair Fastly Compute Edge and Keycloak to check user logins close to your users. This setup lets Keycloak issue tokens while edge workers verify them before traffic hits your backend.

Teams use this pattern to block bad requests early in the network path. Your origin servers stay safe from bad traffic and spend less time checking user keys.

How Fastly Compute Edge and Keycloak share user data

Keycloak acts as your main login server and holds all user accounts and group roles. When a user logs in, Keycloak creates a signed JSON Web Token for that person.

The user sends this token with each web request to your edge app. Fastly Compute Edge reads the token at the nearest point of presence right away.

Your edge code needs public keys from Keycloak to check the token signature. Teams store these public keys in edge dictionaries or fetch them from the Keycloak key endpoint.

Once the edge worker checks the signature, it reads the claims inside the token. The edge code checks expiration times, user roles, and audience tags in a few milliseconds.

If the token fails any check, the edge worker drops the request right there. Valid requests move forward to your backend services with clean user headers attached.

Common failure modes and how to scope roles

Many teams make the mistake of putting broad admin tokens inside edge storage. If an attacker reads that key, they gain full control over your login server.

Shared service accounts between edge apps also create big blind spots in your audit logs. When five edge services use one Keycloak client, you cannot track which app made a call.

Keycloak + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged token checks at the edge can hide brute force attacks from your security team. You must send edge check failures to your main log store for review.

Fix these issues by giving each edge service its own dedicated client in Keycloak. Set up strict role rules so each client only reads the user claims it needs.

Keep token lifetimes short so stolen user keys stop working after a few minutes. Use refresh tokens carefully and revoke them in Keycloak when a user logs out.

Managing key rotation and edge state

Keycloak rotates its signing keys on a set schedule to keep tokens safe. If your edge app holds old public keys, valid users will see login errors.

You can fix this by setting a short cache time on your public key store. When Keycloak adds a new key, the edge worker fetches the updated list on the next miss.

Test your key rotation flow in a staging setup before you push rules to production. Check that old tokens fail right after you revoke a compromised signing key in Keycloak.

Limit network paths so only known edge nodes can talk to your internal backend apps. Your backend should still check that traffic came through your edge network using mutual TLS.

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

How does Fastly Compute Edge verify Keycloak tokens without high latency?

The edge worker caches public signing keys from Keycloak in local edge memory. It checks token signatures at the edge without calling Keycloak on every request.

What happens when a user logs out of Keycloak before their token expires?

Short token lifetimes limit this risk to a few minutes in most setups. For instant revocation, push revoked token IDs to an edge key-value store for quick checks.

Should backend apps still check user roles after the edge worker approves a request?

Yes, your backend apps should still check role claims for sensitive data writes. Edge checks block bad traffic early, while backend checks protect core data rules.

The query runs. The emails stay hidden.