Building a Read‑Only Cloudflare Worker AI Security Console
说明与用途
构建了一个只读的 Cloudflare Worker AI 安全控制台,聚合分析数据,提供自然语言查询、摘要和 Ray‑ID 调查,同时限制 AI 权限并执行访问控制。
问题
Security teams have data but lack a fast, readable operational view that keeps AI from gaining unsafe authority.
结果
The console delivers a read‑only, AI‑augmented security dashboard that lets analysts query data in natural language, view curated queries, receive daily digests, and investigate Ray IDs—all while preventing the AI from modifying Cloudflare resources.
工作流
- Create a read‑only Analytics API token with minimal permissions
- Bootstrap a Cloudflare Worker named sentinel‑cf
- Protect the Worker with Cloudflare Access (policy, MFA, short session)
- Add a Workers AI binding named AI
- Create and bind a KV namespace for latest digests
- Configure an AI Gateway for observability and rate limiting
- Add runtime variables and secrets (CF_ANALYTICS_TOKEN, APP_HOSTNAME, AI_GATEWAY_ID, ALLOWED_ZONE_TAGS, ENVIRONMENT, DEFAULT_DIGEST_RANGE, DIGEST_TITLE)
- Deploy the Worker code (sentinel‑cf‑worker.js)
- Test each endpoint (/, /query, /allowed‑queries, /digest, /ray, /healthz)
- Codify the configuration with Terraform for production
- Schedule daily digests via Cron Trigger and store in KV
证据
The model should not be the administrator.
Workers AI owns: Intent classification when deterministic matching is not enough.
The right production pattern is: AI recommends, humans approve, Terraform or approved change control applies.
- 记录日期: 2026-09-07T02:07:29.957Z