When multi-hop microservices or AI agents must narrow user permissions at 100K RPS without bottlenecking a central Identity Provider, issue Biscuit root tokens at the edge, attenuate caveats offline per hop, and verify locally with a 5-second cache and bounded revocation set.
TL;DR30-second simplified summary▾
In a 100K RPS microservice and AI-agent platform where requests fan out across 4–6 internal hops, calling a central Authorization / IdP service on every hop to exchange narrowed JWTs adds 4–6x load to the IdP and turns it into a latency bottleneck.
A Zero-Trust Delegated Authorization Gateway issues root Biscuit capability tokens at the edge, lets intermediate services and AI agents attenuate tokens offline with narrow Datalog caveats (op=read, resource=..., exp < now + 60s), and verifies tokens locally at every downstream service using the edge public key + a 5-second cached Datalog evaluation.
Emergency revocations propagate via compact revocation_id push streams (Redis Pub/Sub -> local in-memory Bloom/HashSet), bounded by Datalog execution step limits to prevent adversarial token CPU DoS.
Eliminating 5-Hop IdP Bottlenecks & Confused Deputies at 100K RPS.
Why this matters: Establish the multi-hop delegation scenario, zero-IdP-hop latency goal, and emergency revocation requirements.
Suppose a user asks your platform's AI orchestrator to summarize a private Drive folder. The request traverses API Gateway -> Agent Planner -> Document Fetcher -> Storage Service. Forwarding a broad OAuth2 JWT lets a prompt-injected Document Fetcher delete files; calling OAuth2 Token Exchange on every hop adds 40–80 ms and crashes the IdP during traffic spikes.
Functional & Non-Functional Targets:
- 100K edge RPS (~400K internal downstream verifications/sec across 4 hops).
- Offline attenuation at every hop with zero synchronous IdP calls on the hot path.
- <2 ms p99 local token verification + Datalog check.
- <5s emergency revocation propagation for compromised root sessions.
Public-Key Edge Verification + Offline Multi-Hop Attenuation
Services attenuate Biscuit tokens offline and verify downstream using only the issuer's public key.
Sizing Ed25519 Verification CPU & Revocation Set Memory.
Why this matters: Calculate exact CPU cores needed for 400K Ed25519 verifications/sec and how a 5s local verification cache cuts CPU by 10x.
Illustrative CPU Math: At 100K edge RPS × 4 hops = 400,000 token verifications/sec cluster-wide. A 3-block Biscuit Ed25519 verification takes ~150–200 us on one core (~5,000–6,500 verifications/sec/core). Without caching, 400K/s requires ~65–80 dedicated CPU cores just for signature math!
Caching verified (sha256(raw_token), policy_hash) -> allow/deny in a 5-second process-local LRU (bounded to min(5s, token_ttl_remaining)) absorbs repeated multi-call bursts from the same agent session—cutting CPU by ~5–10x in fan-out workloads (exact hit rate depends on per-request token reuse).
Cutting 400K/s Ed25519 Verification Overhead with 5s Local Caching
Short-lived local verification caching and 3.2 MB revocation sets keep p99 auth latency under 2 ms.
Revocation Stream, Datalog Policy Facts & Fail-Closed HTTP 401/403.
Why this matters: Define the token block schema, revocation push stream, and explicit HTTP error semantics.
Every Biscuit block carries a unique revocation_id (SHA256(block_signature)). When a user clicks 'Sign out everywhere' or an API key is compromised, the Issuer writes (revocation_id, expires_at) to PostgreSQL and broadcasts it over Redis Pub/Sub.
API Contract:
401 Unauthorized: Invalid Ed25519 signature, malformed block, expiredttl, orrevocation_idhit.403 Forbidden: Signature valid, but Datalogcheck ifpolicy fails (e.g.,op=writeattempted onop=readattenuated token).400 Bad Request: Token exceedsmax_blocks = 8or Datalogmax_facts = 256(anti-DoS cap).
Hydrated Revocation Set + Fail-Closed Datalog Enforcement
Local revocation sets, Ed25519 verification, and Datalog policy evaluation execute in <2 ms without IdP calls.
Interactive Visual Simulation
Multi-Hop Delegated Auth & Emergency Revocation
Edge Gateway
Mints / Attenuates
AI Agent
Adds read + 60s
Storage API
Revoke + Datalog
blocks
2
caveat
op=read, ttl=60s
idp_calls
0
Datalog DoS Bounds, Key Rotation & Safe Verifier Middleware.
Why this matters: Protect Datalog evaluators against CPU exhaustion bombs and handle multi-key Ed25519 rotation cleanly.
Because any intermediate caller can append Datalog blocks, an adversarial caller could craft a 50-block token with recursive rules designed to stall the verifier's CPU.
MAX_BLOCKS = 8
MAX_TOKEN_BYTES = 4096
def verify_biscuit_middleware(raw_token: bytes, pubkeys: dict[str, bytes], revoke_set: set[bytes], evaluator) -> dict:
if not raw_token or len(raw_token) > MAX_TOKEN_BYTES:
return {'allow': False, 'status': 400, 'reason': 'Token size exceeds 4KB cap'}
parsed = evaluator.parse(raw_token)
if len(parsed.blocks) > MAX_BLOCKS:
return {'allow': False, 'status': 400, 'reason': 'Block chain exceeds depth 8'}
if any(b.revocation_id in revoke_set for b in parsed.blocks):
return {'allow': False, 'status': 401, 'reason': 'Block revoked'}
pk = pubkeys.get(parsed.root_key_id)
if not pk or not evaluator.verify_signatures(parsed, pk):
return {'allow': False, 'status': 401, 'reason': 'Invalid signature or unknown key_id'}
if not evaluator.run_datalog(parsed, max_facts=256, max_iterations=100, timeout_ms=2):
return {'allow': False, 'status': 403, 'reason': 'Policy denied or budget exceeded'}
return {'allow': True, 'status': 200}- Problem
- Untrusted or compromised intermediate agents could craft huge Biscuit chains or need emergency revocation.
- Naive Solution
- Allow unbounded Biscuit blocks and omit revocation checks to keep verification 100% stateless.
- Why It Fails
- Adversarial tokens trigger Datalog CPU DoS, and stolen 1-hour root tokens remain valid until expiry.
- Alternatives
- Pure stateless short-TTL (30s) tokens vs. 1h tokens + bounded Datalog + compact revocation stream.
- Engineering Decision
- Enforce 4 KB / 8-block / 2 ms Datalog caps plus a 3.2 MB Pub/Sub revocation set hydrated from DB on boot.
- Trade-Offs
- Adds ~3 MB RAM and a 1–5s revocation propagation window in exchange for 1h UX and DoS immunity.
A Storage pod restarts during a traffic spike and hasn't finished downloading the active revocation_id snapshot from PostgreSQL yet. A request arrives with a valid Ed25519 Biscuit. What should the pod do?
Trade-Offs, Assumptions, Limitations & Glossary.
Why this matters: Evaluate when capability tokens beat OAuth2 JWTs, document revocation propagation bounds, and define core terms.
Assumptions & Limitations
- Propagation Lag: Pub/Sub revocation updates propagate in ~1–5s; if a Redis Pub/Sub disconnect occurs, pods fall back to periodic 10s DB delta polls and fail closed if stale beyond
max_revoke_staleness. - Clock Skew: Time-bounded caveats (
ttl=60s) assume NTP clock skew under 1–2s across services. - When NOT to Use: Simple single-hop APIs without delegation are simpler with standard OAuth2 JWTs.
Concise Glossary
- Offline Attenuation: Appending restrictive caveats locally without contacting the issuer.
- Biscuit: Asymmetric Ed25519 capability token with an embedded bounded Datalog policy engine.
- Revocation ID: Deterministic per-block identifier (
SHA256(sig)) used to blacklist compromised tokens. - SPIFFE SVID: Short-lived mTLS workload identity certificate authenticating service-to-service callers.
- Fail Closed: Rejecting requests (401/503) whenever policy, key, or revocation state is unknown or unavailable.
Readiness Hydration, Pub/Sub Fallback & Datalog DoS Caps
Boot-time revocation hydration, 10s DB poll fallbacks, and 4 KB/8-block caps harden delegated auth at 100K RPS.
Practice: Make the trade-off yourself.
Why does caching verified Biscuit evaluations for 5 seconds (`sha256(raw_token)`) cut CPU from ~80 cores to ~8–16 cores in a 400K/s fan-out?