Verify with a Cloudflare Worker (no code)
The ready-made Worker checks the Assay signature before forwarding a request to your API. You do not change your application code. You do need a Cloudflare account and a way to restrict access to your origin server, the API behind the Worker.
How it works
Section titled “How it works”Assay calls the Worker’s public HTTPS address. The Worker verifies the request against Assay’s public keys, then sends valid calls to ORIGIN_URL. Invalid signatures get 401; your origin is not called.
Deploy and configure
Section titled “Deploy and configure”- Open Deploy to Cloudflare, sign in to Cloudflare and deploy the ready-made Worker.
- In the repository Cloudflare created for you, set
ORIGIN_URLinwrangler.tomlunder[vars]to your origin, for examplehttps://origin.example.com, and commit it. An optional path prefix is allowed. Do not point it back to the Worker. A value set only in the Cloudflare dashboard is replaced bywrangler.tomlon the next deploy. - Attach the Worker to the public hostname Assay will call, using a route or custom domain. For example, use
api.example.comfor the Worker andorigin.example.comfor the origin. - Restrict the origin to requests from the Worker. If your gateway already checks a secret header, set the Worker’s
ORIGIN_SECRETsecret withnpx wrangler secret put ORIGIN_SECRETand require that value inx-assay-origin-secretat the origin. Otherwise, arrange a private origin connection such as Cloudflare Tunnel, with no public bypass. Configuring the Worker secret alone does not restrict the origin. - Sign in to Assay and open your listing’s Connect & test step.
- Set Your API’s address to the Worker’s HTTPS address, including the path your tool needs. Assay must sign the Worker’s hostname, not the origin’s hostname.
- Under Authentication, choose Assay signature (recommended).
- Fill in the tool’s test input and click Save and run test, or Run the test again.
Check it worked
Section titled “Check it worked”The signed call should reach your origin and pass the test. There should be no Signature not enforced warning. Check that a direct call to the origin cannot bypass the gateway.
You can also check the public route without a signature. Replace this example with your Worker’s address and a path it protects:
curl -i https://api.example.com/v1/searchExpect status 401, content-type: application/json and this body:
{"error":"invalid_assay_signature","reason":"MISSING"}Details
Section titled “Details”| Setting or behavior | Default / result |
|---|---|
ORIGIN_URL |
Required deployment setting; replace the template’s https://origin.example.com. The Worker appends the incoming path and query to the origin’s path prefix. |
JWKS_URL |
Leave unset to fetch Assay’s public keys from https://api.goassay.ai/.well-known/assay-request-keys.json. |
ORIGIN_SECRET |
Unset. When set, the Worker adds x-assay-origin-secret on forwarded calls. |
| Request body cap | 5 MiB (5,242,880 bytes), buffered before verification. Larger bodies get 413 {"error":"payload_too_large"}. |
| Forwarded request | Same method and body. Removes Signature, Signature-Input, Content-Digest and Host; keeps X-Assay-Call-Id. |
| Origin redirects | Returned to the caller; the Worker does not follow them. Use an origin URL that answers directly. |
| Replay store | In-memory per Worker instance. A captured request can be accepted again on another instance while its signature is still valid. |
Optional: reject replays across Worker instances
Enable the supplied NONCE_STORE Durable Object binding and its NonceStore migration in worker/wrangler.toml, then redeploy. Also set NONCE_LOCATION_HINT (for example weur or enam) under [vars] to a region near your origin. This changes deployment configuration and adds a shared storage call per verified request. If the store is unavailable, the Worker returns 503 {"error":"replay_store_unavailable"} and does not forward the call.
Errors
Section titled “Errors”| Symptom | Fix |
|---|---|
Valid Assay calls get 401. |
Keep the incoming method, host, path, query and body unchanged until verification. Use the Worker address in Assay. |
| Signature not enforced | Check that the route actually runs the Worker and the origin has no public bypass. |
Calls get 413. |
Keep bodies within the Worker’s cap. |
Go further
Section titled “Go further”- List your API (optional): Or: publish your own API.
- Verify in your code (Node, Python, Go) — an alternative to the Worker.
