Skip to main content

Posts

Showing posts with the label Architecture

PreSigned Url vs Token based

Presigned URLs vs. Token‑based Access Architecting a system where only your platform owns the data. A deep dive into Cloudflare R2 security patterns. 1. Presigned URLs The standard industry approach. The backend generates a specific URL with a cryptographic signature and an expiration time. GET https://bucket.r2.dev/image.png?X-Amz-Signature=a1b2...&Expires=171000 ✅ The Pros Zero Runtime Cost: Traffic goes directly from R2 to the client; no compute needed. Simple Implementation: Standard S3 SDK feature. Hard Expiry: Access is mathematically impossible after the timestamp. ❌ The Cons Weak Caching: Every signature is unique. `image.png?sig=A` != `image.png?sig=B` Leaky: If a user shares the URL, anyone can view it until expiry. No Revocation: You cannot block a speci...