Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Marketplace Object Storage Downloads: How to Generate Pre-Signed URLs for Tenant Files in Node.js

Short answer: authorize the report request before you create a signed object-storage URL, and make the object key tenant-specific. Treat the URL as a short-lived capability, not as proof that the requester may see the report. For a marketplace serving generated reports, the useful decision rule is simple: choose a server-mediated download when every access must be rechecked; choose a signed link…

To create signed download URLs for tenant files in Node.js, follow these steps. First, confirm the authenticated principal is associated with a tenant and valid report record. Next, verify the report's state and intended recipient before interacting with object storage. In Node.js, generate pre-signed download URLs by receiving a report ID and principal, deriving the object key from trusted data, and never letting raw browser paths select files. The server should always handle lookup, never trusting browser-provided keys.

Use a data structure like this for reports:

```javascript

type Report = {

id: string;

tenantId: string;

objectKey: string;

state: "ready" | "processing" | "failed";

contentType: string;

};

```

Create a function to check if a user can download a report:

```javascript

function canDownload(report: Report, tenantId: string): boolean {

return report.tenantId === tenantId && report.state === "ready";

}

```

Retrieve the report based on the browser-provided ID, not the object key. The object key should be derived from the server-side report record. Prefix the key with the tenant identifier for easier auditing, though the prefix alone doesn't provide security. The final object key might look like "tenants/t_482/reports/r_901/export.csv". Keep the tenant identifier in the key prefix to aid in spotting mistakes.

Log the authorization decisions with necessary details like principal, tenant, report ID, object key, outcome, and expiry. Avoid placing signed URLs in standard application logs to prevent leaking through various channels.

To prevent tenant escape, separate four boundaries: identity (established by API session or token), ownership (decided from server-side data), capability scope (narrow, one object, one read operation, limited interval), and response behavior (minimal disclosure). Always validate tenantId in a route, then perform object lookup in a separate function. This approach makes authorization testing easier and ensures separation from storage infrastructure changes.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

A peso that is worth zero for 55 steps, and the median ceases to be the median

A weight that is worth zero for 55 steps, and the median ceases to be the median The number An estimator of mine published 2.2380708362e+251 as the median of 3894 values.

  • A fictitious weight of zero affected 55 steps in a calculation
  • Median changed from correct value of 6.8003333871e+250 to 2.2380708362e+251
  • Problem occurred when scale exceeded representable state

Multipath TCP vs Single-Path TCP: Why One Connection Refuses to Pick a Lane

For decades, a TCP connection has been defined by four numbers: the two addresses and the two ports at either end. Change one of them and the connection is over.

  • Multipath TCP (MP-TCP) maintains connection identity across network changes.
  • MP-TCP adds connection-level layer for seamless handshakes and subflow management.
  • Benefits include bandwidth aggregation and network continuity, but deployment faces challenges.

Why 1.26 cubic metres of concrete comes out as 70 bags, or 71, depending on where you round

A 4 by 3 metre slab at 100 mm deep is 1.2 cubic metres. Add the usual 5 percent margin and you have 1.26. Divide by the yield on the bag and the order should be 70 bags.

  • Concrete volume, margin, bag yield, and rounding precision determine bag count
  • 4 m by 3 m slab with 0.1 m depth requires 1.26 cubic meters of concrete
  • Rounding 70.00000000000001 up yields 71 bags, but rounding ratio first yields 70 bags

More from Saturday, 28 November 2026 →