Short answer: make the export record, not the object URL, your source of truth. Authorize the tenant against that record, issue a short-lived presigned download URL, and measure the record all the way through deletion.
For an e-commerce platform, a training bundle is usually a ZIP of product guides, images, and a manifest. The old mental model is “upload, make a link, send email.” The safer model is a small state machine: created -> ready -> url_issued -> deleted. Object storage carries bytes; the application owns tenant isolation and retention.
That distinction is the useful design decision. A URL can be valid and still point at the wrong tenant, survive the retention deadline, or be consumed by an automated mail scanner before a human clicks it.
Links are credentials.
Start with a retention record, not a bucket path
Give every export an immutable record containing tenantId, exportId, objectKey, state, expiresAt, and a checksum. The request should contain only an export ID. The server loads the row, checks the authenticated tenant, and derives the object key. A user-supplied tenant string must never become a bucket prefix by concatenation.
Retention is an application decision and a storage policy. Compare expiresAt with the current time at every download request. Return 410 Gone for an expired export and 409 Conflict while it is still assembling. A lifecycle rule remains a useful cleanup backstop, but it is not evidence that deletion happened on time.
Here is the narrow boundary I use in Node.js. It keeps provider syntax out of the authorization path and makes the policy easy to unit-test.
type ExportRecord = { tenantId: string; objectKey: string; state: "ready" | "assembling" | "expired"; expiresAt: Date; }; type PrivateStore = { headObject(input: { bucket: string; key: string }): Promise<{ size: number }>; presignGet(input: { bucket: string; key: string; expiresInSeconds: number; contentDisposition: string; }): Promise<string>; }; async function issueExportLink( record: ExportRecord, requesterTenantId: string, store: PrivateStore, bucket: string, ): Promise<string> { if (record.tenantId !== requesterTenantId) throw new Error("forbidden"); if (record.state !== "ready") throw new Error("export_not_ready"); if (record.expiresAt.getTime() <= Date.now()) throw new Error("export_expired"); await store.headObject({ bucket, key: record.objectKey }); return store.presignGet({ bucket, key: record.objectKey, expiresInSeconds: 120, contentDisposition: "attachment; filename=training-export.zip", }); } The metadata check is intentional. It confirms that the object is visible before a link is issued, instead of trusting an earlier upload acknowledgement. Emit an export.download_url_issued event with tenant, export, expiry, and a request ID. Never put the signed URL in logs; its query string is a bearer credential.
Which Node.js presigned download URL flow protects a private export?
Use an authenticated application link as the durable bookmark, then redirect to a newly signed object URL. The application link can be disabled when a tenant is suspended and can record a redemption. The object itself stays private. Keep redemption idempotent because scanners and previews may request a URL before the recipient does.
For a browser navigation, CORS does not gate the download. CORS matters when a front end uses fetch() or XHR and reads the response in JavaScript. If the training UI needs progress or client-side ZIP inspection, allow only its exact origin, method, and response headers, and test the preflight from the deployed origin. A permissive wildcard is a poor substitute for tenant authorization.
Presigned URLs are bearer tokens, so expiry is a risk budget, not a revocation system. Two minutes may fit a small bundle; a large export, range requests, or a corporate scanner may need a different value. Signature V4 URLs have a seven-day maximum, and temporary signing credentials can end sooner. I’m not sure which delay your object store’s lifecycle scheduler will show, so verify it in a disposable bucket and record the observation.
Make publication and deletion observable
The worker should write the object, collect its metadata, and then mark the database row ready. The signer performs its own metadata check. This ordering prevents a queue consumer from seeing ready before the bytes are available. Retries use an idempotency key such as exportId:recipientId; delayed messages still re-check expiresAt and cannot resurrect an expired export. In practice, the interesting trace is the gap between those operations: a worker may finish uploading at 10:02:14, the database transaction may commit at 10:02:15, and a mail job may be dequeued at 10:02:15.2. If the signer trusts only the row, it can hand out a link before a reader can see the object. Recording the object size and checksum with the state transition gives the API something concrete to verify, while the request ID ties the check, the redirect, and the eventual download to one searchable record. That small amount of bookkeeping also makes a retry boring: the same export and recipient produce one redemption event instead of a trail of apparently different links.
Track four transitions: created, ready, url_issued, and deleted. Useful alerts include tenant and export IDs, never the URL. A spike in url_issued without downloads may mean an email prefetcher, a broken message, or an authorization mistake. A 404 after ready points to a publication race or cleanup that ran too early.
I also run one cross-tenant negative test on every deploy: tenant A must receive 403 for tenant B’s export ID, even when the ID is guessed correctly. It is a tiny test. It catches the expensive class of isolation regression.
Test the denial path.
Choose the control point that matches the threat
| Delivery shape | Isolation and retention control | Strength | Cost or limitation |
|---|---|---|---|
| Authenticated redirect to presigned GET | Application before signing | Simple clients and direct transfer | A forwarded URL works until expiry |
| CDN signed URL or cookie | Edge policy plus private origin | Efficient repeated downloads | Cache-key errors can mix authorization contexts |
| Application streaming | Auth service for every byte | Central byte-level audit | Long connections consume app capacity |
| One-time proxy token | Transactional redemption store | Strong replay control | A scanner can spend the token first |
There is no universal winner. Streaming is not suitable for multi-gigabyte catalog exports unless regulation requires byte-level mediation. One-time tokens are a bad fit when recipients rely on scanners or resumable downloads. A CDN deserves a separate review when the same tenant repeatedly downloads the same artifact. For ordinary training exports, the redirect flow keeps policy and data transfer separate without pretending the URL is permanent.
The catch is deletion: URL expiry does not delete an object. If a compliance rule demands immediate revocation of already issued links, use a proxy or an edge policy with a revocation list. Otherwise, keep the retention ledger authoritative, reconcile it with object metadata, and alert on records that remain past their deadline.
References
- MDN, Cross-Origin Resource Sharing (CORS): https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- Amazon S3 User Guide, Using presigned URLs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- MDN, Content-Disposition header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition
- RFC 9110, HTTP Semantics: https://www.rfc-editor.org/rfc/rfc9110

