Skip to main content
Every option is passed to ZeroClick::Sellers.create, or set on config.zeroclick under Rails.

Options

Signing secrets

A map rather than a single secret, because rotation is the normal case: while ZeroClick is switching, requests arrive signed with either kid, and both must verify. Remove the old entry only once no traffic carries it. If your secrets live in a vault rather than the environment, pass a resolver instead:
Provide exactly one of signing_secrets or resolve_signing_secret — giving both, or neither, raises at construction rather than at the first request.

Split usage keys

Useful when a separate process reports usage — a Sidekiq worker settling variable work, say. The reporting process then needs no read scope, and the serving process needs no write scope.

The allowance-unavailable policy

When the allowance API cannot give an answer — a timeout, a 5xx, an unparseable body — this decides what happens.
The policy applies only after a signature verifies. A fail-open allowance policy never becomes a fail-open signature policy — an unsigned or badly signed request is refused with 401 under every policy.
A recognised allowed: false is always a 402, never an outage — the API answered, and the answer was no. An Allow reached through the policy reports allowance == "unavailable" rather than "allowed", so you can distinguish served-because-we-could-not-check from served-because-they-paid:

Timeouts

check_timeout_seconds bounds the allowance check, which sits in your request path — it applies to connect, read and write. The default of 1.5 seconds trades a slow check for a fast fail-open. Raise it only if your outage policy is "deny" and you would rather wait than refuse.

Body size

The middleware buffers the request body to verify it, bounded at 10 MiB by default:
The ceiling is enforced before verification, on purpose: an attacker needs no valid signature to make you buffer. An over-size body is refused with 413.