GCP API Gateway
For GCP managed gateway stacks, use an external authorization pattern that calls Fairvisor before backend proxying.
Architecture
Client -> API Gateway / ESPv2 -> auth check -> Fairvisor /v1/decision
| allow -> backend
| reject -> 429
Required decision headers
Forward these to Fairvisor on each decision request:
X-Original-MethodX-Original-URI(full path + query)Authorization(if JWT claims are used)X-Forwarded-For(original client IP)
External auth service contract
Your auth hook (service, middleware, or sidecar) should:
- Build Fairvisor decision request from incoming gateway request
- Call
POST /v1/decision - If
200, continue to backend - If
429, stop pipeline and return reject with Fairvisor headers
Practical config guidance
- Keep Fairvisor call timeout in 200-500 ms range
- Do not perform repeated retries in auth path
- Treat decision timeout/unreachable as explicit fail-open or fail-closed policy per route
Reference policy split: Gateway Failure Policy.
Observability
Capture and monitor:
- decision call latency
- decision status distribution (
200/429/503) - fallback events (fail-open or fail-closed path)
- reject reason breakdown from
X-Fairvisor-Reason
Security hardening
- Keep Fairvisor endpoint private to GCP network boundary
- Validate that only trusted gateway/auth components can call decision endpoint
- Never trust user-provided
X-Original-*headers directly from internet clients
Validation checklist
- Send known-allowed request and verify backend pass-through
- Send known-rejected request and verify
429+Retry-After - Confirm
X-Fairvisor-Reasonis logged and propagated as intended - Simulate Fairvisor outage and validate chosen failure policy
See Decision API for endpoint details.