Twenty minutes of streaming to say yes
A shop that sells sample packs to music producers keeps each pack, a 3 GB archive of WAV files, in a private bucket. Its download endpoint checks that the logged-in buyer paid for the pack, one row in the purchases table, then streams the archive from the bucket through the app server. On a release day 4,000 buyers download the same new pack: 12 TB through servers whose real work was 4,000 row lookups. Each stream holds a connection for as long as the buyer's line needs, twenty minutes on a slow one, so the fleet is sized for bandwidth, not for the work only it can do.
Only the lookup needs the shop's code. Moving the bytes needs nobody but the store. So the server can make the check, then hand the buyer something that opens that one archive for a few minutes, and the browser fetches the bytes from the store itself. That something is a Valet Key: a key with a narrow scope and a short life, issued by the service that knows the rules and used by a client to reach one resource directly. The name comes from the car key a valet gets, which starts the engine and opens nothing else; unlike that key, most of these cannot be taken back.
The API checks the purchase and signs a link; the archive goes from the bucket to the buyer. The bucket verifies the signature itself and never calls the API.
What the signature says
The common form is the presigned URL, S3's name for it; Google Cloud Storage calls it a signed URL and Azure a shared access signature (SAS). The API describes the request it is willing to allow, GET on packs/lofi-keys-vol3.zip for the next 300 seconds, and signs that description with a credential the store trusts. The result is an ordinary URL to the store, with the parameters and the signature in its query string. When the browser requests it, the store recomputes the signature, checks the expiry and the operation, and serves the object without asking the shop anything. Nothing the signature covers can be edited: point it at another pack, or ask for a different operation, and the signature no longer matches.
The scope is whatever the signature pins:
- The object. One key in the bucket, not the bucket. A key that covers a whole prefix or container is a broader grant, sometimes the right one, for an album of files, and always worth noticing.
- The operation.
GETto read,PUTto write. A link signed for a read cannot replace the pack for everyone else. - The expiry. A download link needs minutes. S3 and Google Cloud Storage cap a V4-signed URL at 7 days, and an S3 URL signed with temporary credentials ends when they do.
- Size and content type, for uploads. Where the store supports it, the issuer signs the exact length and declared type it approved, or on S3 a POST policy with a size range, and the store refuses a request whose length or declared type does not match.
A key is never wider than whoever signed it: an S3 presigned URL carries the permissions of the identity that created it, so the shop signs with a role that can read the packs and nothing more. That signing credential is the real secret. It stays on the server; the client only ever sees what it produced.
Check first, then sign
The store enforces what the signature pins and nothing else. It does not know who bought what. So every rule runs in the issuer, before it signs: is this buyer logged in, did they pay for this pack, has the purchase been refunded, have they asked for 40 links in the last hour. Then the API takes the object key from the purchase row, not from the request. An API that signs whatever key the client names hands a buyer who edits vol3 to vol4 a perfectly valid link to a pack they never bought.
A link on a forum
A week after a launch, the shop finds one of its links pasted into a forum thread. A presigned URL is a bearer credential: the store checks the signature, not the person presenting it, so anyone who holds the URL can use it, as often as they like, until it expires. This one was signed for 300 seconds, and by the time anyone clicked it in the thread it answered 403. Week-long links, for re-downloads from a receipt email, would have given the forum a week of free packs.
Expiry is the defence, because a single link mostly cannot be recalled: a store typically keeps no list of the URLs signed against it, so there is nothing to delete. What remains is the credential that signed it: a signed URL works until it expires or until that credential stops being valid, on S3 when it is revoked, deleted or deactivated. Disabling it cancels every link it signed, the honest buyers' too, so it is an emergency measure, not a way to cancel one link; merely starting to sign with a new key does not by itself invalidate the old one.
S3 checks the expiry when a request arrives, so a download that starts at second 290 still finishes, and a retry after the expiry needs a fresh link. The download button therefore asks the API for a new link each time, which also logs every issue and lets a cap per purchase expose a shared account; and a full signed URL in an access log or a support ticket works until it expires, so it is handled as a secret.
Uploads arrive unchecked
Producers upload their packs the same way: the API checks that the seller may publish, chooses the object key and signs a PUT for the declared length and content type. The bucket checks what was signed and nothing more, so a file of the right length labelled application/zip can still be corrupt, or malware; Gatekeeper covers why a request that passed its checks is not yet a safe one.
So uploads land where nothing serves them and are checked before buyers can reach them, the Quarantine pattern; Large file upload covers the rest of the path for big files.
Where a key is the wrong tool
A key scoped too broadly, or with an expiry set too long, stops being a valet key: a bucket-wide link is a wide-access credential and a week-long one a long-lived one, and leaked once, either exposes everything it covers for as long as it lives.
Some requests should not skip your servers. When every read must be checked as it happens, or the bytes must change on the way, a watermark per buyer for instance, a link valid for minutes is too coarse, and the request goes through a service that checks it in front of the store, as Gatekeeper does. Public files need no key: Static Content Hosting serves them from storage and a CDN. How the bucket itself behaves is Object storage & blobs.
Practice from the store's side
The Object Storage Service Challenge lists "Enforce per-bucket access control and signed URLs" among its requirements, and here you build the store. Draw where a signed URL is verified, at the access-control check in front of the storage fleet and at the CDN for hot reads, and write in a title what the signature pins: object, operation, expiry. Sharing in File Storage & Sync is a second place to try it: decide what a shared link lets its holder do, and for how long.