Secrets Store Demo
Read account-scoped secrets from Cloudflare Secrets Store
Read an account-scoped secret from Cloudflare Secrets Store without ever returning the full value - only status, length, a short preview, or a boolean match.
Features
GET /secret/status- whether configured, length, and 2-character previewGET /secret/verify?expected=- compare without logging or returning the secret
API Reference
GET /secret/status
Example Request
curl "https://your-worker.workers.dev/secret/status"Success Response (configured)
{
"configured": true,
"length": 12,
"preview": "ab***"
}Success Response (missing)
{
"configured": false
}GET /secret/verify
Compare a candidate value to the stored secret.
expected string (required)
Example Request
curl "https://your-worker.workers.dev/secret/verify?expected=my-secret-value"Success Response
{
"match": true
}Error Codes
400- Missing or emptyexpected(MISSING_PARAM)
Use Cases
- Learn Secrets Store Workers bindings safely
- Verify API keys without exposing secret values in responses
- Prototype account-scoped secret checks vs per-Worker secrets
- Teach secure secret handling patterns at the edge
Limitations
- Never returns the full secret value
- Requires a real Secrets Store
store_idand secret name - Bindings may need remote/dev account access locally
- Demo uses a single
API_KEYbinding only
Deployment
Configure Secrets Store
- Create a Secrets Store and a secret named
demo-api-key - Set
store_idinwrangler.jsonundersecrets_store_secretsfor bindingAPI_KEY
Test your deployment
curl "https://your-worker.workers.dev/secret/status"Local Development
cd apps/experiments/secrets-store-demo
npm install
npm run devcurl "http://localhost:8787/secret/status"Secrets Store bindings may require a remote/dev account; unit tests mock API_KEY.get.
Configuration
wrangler.json declares:
- Secrets Store secret binding
API_KEYwithstore_idandsecret_name: "demo-api-key"
Cloudflare Features Used
- Workers - Edge compute runtime
- Secrets Store - Account-scoped secrets