# Zero-Trust Access Gate: Verifying RS256 JWKS with Web Crypto
Exposing an internal CRM holding client records, proposals, and 3-tranche payment tracking behind a standard password form widens the attack surface unnecessarily. Authentication is offloaded to Cloudflare Access, while the Worker independently re-verifies every incoming request cryptographically.
The Cf-Access-Jwt-Assertion header or CF_Authorization cookie is verified via Web Crypto API (RSASSA-PKCS1-v1_5 + SHA-256) against a 5-minute cached JWKS endpoint, automatically refreshing keys on an unknown kid to handle key rotation seamlessly.
- Every API route enforces iss, aud, exp, nbf, and a strict single-operator email allowlist.
- Responses enforce Cache-Control: no-store, X-Robots-Tag: noindex, nofollow, noarchive, nosniff, and SAMEORIGIN.
- Unauthorized calls terminate immediately with 403 and zero data exposure.
# Eliminating Crawler Noise: IP-Bound HMAC-SHA256 Telemetry Beacon
Naive visit counters on live client demo links are quickly polluted by WhatsApp/Instagram link previewers, automated scrapers, AI crawlers, and the developer’s own test sessions.
To isolate genuine human engagement, the edge demo worker signs a short-lived HMAC-SHA256 visit token bound to the visitor IP. The 1×1 GIF beacon is accepted only within a valid dwell window (800 ms–30 min) alongside scroll and interaction metrics.
- Filters Cloudflare verified bots, social link previewers, prefetch requests, missing Accept-Language headers, and zero-interaction datacenter ASNs.
- Automatically tags operator panel IPs in an own-devices table so owner traffic never contaminates client visit KPIs.
- Computes unique visitors via truncated SHA-256(ip|ua) hashing rather than exposing raw telemetry keys.
// Short-lived IP-bound HMAC-SHA256 beacon verification at the edge
const verified = await verifyVisitToken(token, env.VISIT_SIGNING_SECRET, ip, Date.now(), {
minAgeMs: 800,
maxAgeMs: 30 * 60 * 1000,
});
if (!verified.ok || classifyRequestBot(request.headers, request.cf).hardBot) return gifResponse(); # Conflict-Safe Bidirectional D1 and Local SQLite Sync
The exact same UI runs locally on Node.js + SQLite and 24/7 on Cloudflare Workers + D1. A non-destructive PULL-BACKUP-MERGE-PUSH workflow snapshots remote D1 state first and merges new research/templates using SQL ON CONFLICT guards that preserve user_modified workflow stages and payment records.
Related Case Study & Live Browser Tools