An enterprise-ready Google Cloud Service Extensions callout service implementing RFC 9421 HTTP Message Signature for cryptographically verifying Web Bots and AI Crawlers at the Google Cloud Application Load Balancer.
- Overview & Architecture
- Repository Structure & Dependencies
- Prerequisites
- Quick Start
- Running Tests & Utilities
- Interactive Demo UI
- Docker & Cloud Run Deployment
- Terraform Infrastructure Deployment
- Configuration Options
Modern AI crawlers and search indexers sign their HTTP requests per the Web Bot Auth IETF internet draft using asymmetric cryptography.
This repository provides a Service Extensions callout server that:
- Intercepts incoming HTTP request headers via Service Extensions running on Google Cloud Load Balancer.
- Validates HTTP Message Signatures (
Signature-Agent,Signature-Input,Signature) against public keys fetched dynamically from the bot's JWKS directory. - Caches JWKS Public Keys in a thread-safe LRU cache with configurable TTL to minimize latency overhead.
- Mutates Request Headers:
x-verified-bot: true/falsex-bot-agent: The authenticated bot agent URI.x-bot-key-id: The key identifier used to sign the request.x-bot-algorithm: The cryptographic algorithm used (e.g.,ed25519,rsa-pss-sha512).
- Enforcement Modes:
- Observability / Tagging Mode: Annotates headers for downstream routing.
- Enforce Mode: Returns an immediate bot-friendly
HTTP 403 Forbiddenresponse with JSON error details and IETF documentation link.
This repository packages the core web_bot_auth module alongside all necessary Service Extensions frameworks, protobuf definitions, and Terraform:
WebBotAuth-on-google-cloud-load-balancer/
βββ terraform/ # Complete Terraform IAC for Cloud Run, Service Extensions, and Load Balancer
β βββ provider.tf # GCP provider configurations
β βββ variables.tf # Configurable variables
β βββ cloud_run.tf # Cloud Run v2 Callout Service with h2c gRPC support
β βββ callout_service.tf # Serverless NEG, Callout Backend Service & LB Traffic Extension
β βββ sample_lb.tf # Sample External Application Load Balancer & sample upstream origin
β βββ outputs.tf # Load Balancer IP, test curl commands
β βββ terraform.tfvars.example # Example variable values
β βββ README.md # Terraform deployment and testing guide
βββ extproc/
β βββ web_bot_auth/ # Core Web Bot Auth Implementation
β β βββ server.py # WebBotAuthCalloutServer (gRPC Service)
β β βββ verifier.py # RFC 9421 Verification Engine & KeyCache
β β βββ README.md # Module architecture documentation
β β βββ TESTING.md # Detailed testing guide
β β βββ test/ # Test suite & verification utilities
β β β βββ test_web_bot_auth.py # Unit tests
β β β βββ generate_jwks.py # Keypair & JWKS generator
β β β βββ send_signed_request.py # RFC 9421 client request signer
β β βββ ui/ # Interactive Web UI Playground
β β βββ index.html, styles.css, favicon.ico
β β βββ js/ # Modular frontend scripts
β β βββ Dockerfile # Nginx Cloud Run container
β β βββ README.md # UI documentation
β βββ service/ # Service Extensions Callout SDK Framework
β β βββ callout_server.py # Base CalloutServer class & health checks
β β βββ callout_tools.py # Envoy header mutation and response helpers
β βββ ssl_creds/ # Default SSL certificates for secure gRPC
βββ protodef/ # Generated Envoy ext_proc Protobuf & gRPC stubs
β βββ setup.py # Local package installer for proto definitions
β βββ envoy/ # Envoy external processor v3 definitions
β βββ udpa/ # Universal Data Plane API annotations
β βββ validate/ # Protobuf validation stubs
β βββ xds/ # xDS protocol annotations
βββ buf.gen.yaml # Buf configuration for regenerating proto stubs
βββ Dockerfile # Root multi-stage Dockerfile
βββ requirements.txt # Core Python dependencies
βββ requirements-test.txt # Test dependencies (pytest)
- Python: 3.11 or later
- Buf CLI (Optional, only needed if regenerating protobuf stubs): Install Buf
- Docker (Optional, for containerized execution)
Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txtInstall the bundled Envoy protobuf stubs as a local Python package:
pip install ./protodef(Optional) To regenerate the protobuf stubs from the official Envoy API:
buf -v generate https://github.com/envoyproxy/envoy.git#subdir=api \
--path envoy/service/ext_proc/v3/external_processor.proto \
--include-imports
pip install ./protodefStart the Web Bot Auth callout server on plaintext port 8080 with combined health checks:
python -m extproc.web_bot_auth.server --plaintext_port=8080 --combined_health_checkTo enable Enforce Mode (fail-closed HTTP 403 on invalid signatures):
python -m extproc.web_bot_auth.server --plaintext_port=8080 --combined_health_check --enforceExecute the test suite using Python unittest or pytest:
python -m unittest discover -s extproc/web_bot_auth/test -p "test_*.py"Or:
pytest extproc/web_bot_auth/test/test_web_bot_auth.pyGenerate an Ed25519 or RSA key pair and matching jwks.json:
python -m extproc.web_bot_auth.test.generate_jwks \
--alg ed25519 \
--key_id my-crawler-key-1 \
--out_key private_key.pem \
--out_jwks jwks.jsonTest your live deployment by sending an RFC 9421 signed request:
python -m extproc.web_bot_auth.test.send_signed_request \
--url https://your-domain.com/data \
--key private_key.pem \
--key_id my-crawler-key-1 \
--agent_uri https://my-crawler.com/.well-known/jwks.json \
--alg ed25519An interactive web playground is included in extproc/web_bot_auth/ui/ to test signature generation, header inspection, and verification workflows visually in your browser.
To open the UI:
# Open directly in your browser
google-chrome extproc/web_bot_auth/ui/index.html
# Or serve with Python
python -m http.server 8000 --directory extproc/web_bot_auth/uiBuild the container image using the multi-stage Dockerfile:
docker build -t google-cloud-web-bot-auth:latest .Run locally:
docker run -p 8080:8080 google-cloud-web-bot-auth:latestDeploy to Google Cloud Run:
gcloud run deploy web-bot-auth-callout \
--image gcr.io/PROJECT_ID/google-cloud-web-bot-auth:latest \
--platform managed \
--region us-central1 \
--use-http2 \
--port 8080 \
--no-allow-unauthenticatedA complete Terraform module is provided in terraform/ to automatically provision:
- Cloud Run Callout Service: HTTP/2 gRPC
ext_procserver with dedicated Service Account and auto-scaling. - Service Extensions Infrastructure: Serverless NEG, Global Backend Service (
EXTERNAL_MANAGED), andgoogle_network_services_lb_traffic_extension. - Sample External Application Load Balancer: Global IPv4 address, upstream origin Cloud Run app, URL map, and Forwarding Rule.
cd terraform
cp terraform.tfvars.example terraform.tfvars
# Edit project_id and region in terraform.tfvars
terraform init
terraform plan
terraform applySee terraform/README.md for full configuration details and testing instructions.
The callout server accepts the following command-line flags:
| Flag | Default | Description |
|---|---|---|
--plaintext_port |
8080 |
Port for plaintext gRPC / HTTP2 traffic. |
--combined_health_check |
False |
Serves health check endpoints on the gRPC port. |
--enforce |
False |
If set, rejects unauthenticated/invalid bot requests with HTTP 403. |
--allow_http |
False |
Allows http:// URLs for Signature-Agent (testing only). |
--key_ttl |
3600 |
JWKS public key cache TTL in seconds. |
--doc_url |
RFC 9421 | URL included in HTTP 403 responses and Link headers. |
Licensed under the MIT License. See LICENSE for details.
