Skip to content

worker: gate rule publishing on a dedicated SITE_RULES_PUBLISH_KEY secret - #13

Merged
myleshorton merged 1 commit into
mainfrom
publish-key-separate-secret
Aug 8, 2026
Merged

worker: gate rule publishing on a dedicated SITE_RULES_PUBLISH_KEY secret#13
myleshorton merged 1 commit into
mainfrom
publish-key-separate-secret

Conversation

@myleshorton

Copy link
Copy Markdown
Member

Gate rule-publishing on a dedicated secret (not API_KEYS)

Follow-up to #12. The publish: true-on-API_KEYS approach required editing the API_KEYS secret to add a publisher entry — but Cloudflare secrets can't be read back, so editing means re-supplying the whole value, and if you don't have the current customer keys saved, that blind overwrite would wipe them.

This switches POST /v1/site-rules/:key to check the :key against a standalone SITE_RULES_PUBLISH_KEY secret, set independently of API_KEYS:

if (!env.SITE_RULES_PUBLISH_KEY) return 503;      // publishing not configured
if (pubKey !== env.SITE_RULES_PUBLISH_KEY) return 403;
  • No customer key can publish (separate secret entirely).
  • Setting/rotating the publisher token never touches API_KEYS.
  • Docs updated in wrangler.toml + bench/publish-rules.sh.

After merge: redeploy, then openssl rand -hex 24 | npx wrangler secret put SITE_RULES_PUBLISH_KEY.

🤖 Generated with Claude Code

Publishing now checks `:key` against a standalone SITE_RULES_PUBLISH_KEY secret
instead of requiring a publish:true entry in API_KEYS. API_KEYS is unreadable
and must be re-supplied whole to edit, so adding a publisher entry there risked
wiping existing customer keys. A dedicated secret is set independently:
  openssl rand -hex 24 | npx wrangler secret put SITE_RULES_PUBLISH_KEY
503s if the secret is unset; 403s on mismatch. No customer key can publish.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@myleshorton
myleshorton merged commit a867821 into main Aug 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant