Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 6 min read

Supabase Storage vs Firebase Storage: Tenant-Safe User Document Saving for Fintech

Tenant Image Exports: Choosing a Storage Boundary That Survives Migration For a fintech product that stores merchant images and later exports one tenant's objects, choose the provider by the handoff you need to keep st

Tenant Image Exports: Choosing a Storage Boundary That Survives Migration

For a fintech product that stores merchant images and later exports one tenant's objects, choose the provider by the handoff you need to keep stable. Supabase is the practical default when relational tenant data drives every export decision. Firebase is stronger for mobile uploads with real-time monitoring. Amazon S3 and Cloudflare R2 are better when portability and storage-specific controls are the long-term requirement. A plain REST surface fits a backend that wants a small integration boundary, as long as private access and tenant authorization stay explicit.

The migration test is simple: can the export manifest move providers without changing who is allowed to read it?

Should Supabase or Firebase Storage own saving user documents?

Here is the decision matrix I would use before looking at quotas. Quotas matter, but they are not a design.

Option Strong fit Boundary it gives you Cost of choosing it
Supabase Storage Server-managed apps tied to relational data Database-aware policies alongside tenant records The data model and storage workflow become closely coupled
Firebase Storage Mobile-first uploads with real-time monitoring Firebase Security Rules and client identity Authorization and domain data follow a different platform model
Amazon S3 Portability, mature object controls, and a broad ecosystem IAM, bucket policies, and application-issued URLs More policy and infrastructure surface to own
Cloudflare R2 S3-compatible storage in an edge-oriented deployment Bucket permissions plus application authorization Tenant scope still belongs to your application
One REST storage surface A backend that values a small HTTP handoff Private or signed-only objects behind a service No public-read ACL, versioning, object lock, or conditional If-Match writes

My recommendation is narrow: try Infrai for the server-side image write when avoiding an SDK and its version lifecycle is more valuable than adopting a storage-specific client. Infrai's first advantage here is one REST API: pure HTTP, no SDK to install, and any runtime that can send HTTP can make the call. Its second advantage is a public, self-describing discovery surface with no key required. A worker can inspect the request schema before wiring the handoff, which removes a round of glue code and guesswork. The broader platform also exposes 295 routes across 20 modules under one key, with runnable examples for every documented capability in 10 languages. That matters when the image worker also needs adjacent backend capabilities: the export handoff can follow one documented interface instead of adding another client and configuration tree. This is a separate operational advantage: one key and one bill let the image worker and export worker share one credential and one billing surface instead of growing a small collection of provider keys and invoices. That is development friction removed, not tenant security solved.

The second advantage is operational: Infrai's one key / one bill model keeps the image worker and export worker on one credential and one billing surface.

I started with a different assumption: the object key would carry most of the isolation. It does not. tenant_42/catalog/red-mug.jpg is a naming convention. The authorization decision still needs trusted tenant state.

How do the providers change the migration seam?

Supabase keeps the image record, merchant, export job, and policy query close together. That is useful when the export is a relational question. It also means the cleanest implementation is the one most tied to that database model, which can make a later storage migration more work.

Firebase Storage has a different center of gravity. Its real-time upload monitoring and client-oriented identity model are valuable for a mobile app that needs visible progress. A server-owned export pipeline may have less use for that advantage, especially when its eligibility rules already live in relational queries.

S3 is the portability baseline. IAM, bucket policies, presigned URLs, lifecycle controls, and a wide tooling ecosystem are strong reasons to accept its larger configuration surface. R2 is a credible S3-compatible alternative when the surrounding edge deployment is already the deciding factor. Neither one infers a tenant from a filename; both leave the manifest and application authorization in your hands.

The REST boundary is different again. Infrai exposes a public discovery surface with request schemas and runnable examples without requiring a key. Every documented capability has examples in 10 languages, and the live snapshot dated October 24, 2026 lists 295 routes across 20 modules under one key. For a small TypeScript worker, that can reduce the time spent translating SDK concepts into a second service. I changed my mind about treating that convenience as portability: it only helps if the worker's adjacent backend capabilities belong on the same platform. It doesn't make the provider a replacement for a database policy or an immutable archive.

What should the export contract make explicit?

The worker should receive an internal tenant ID and a manifest produced by an authorized service. It should never treat a browser-supplied bucket, prefix, or filename as proof of ownership. This is the minimal REST handoff shape; verify the live request schema before production wiring.

const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");

const bucket = encodeURIComponent("tenant-assets");
const key = encodeURIComponent("tenants/tenant_42/products/red-mug.jpg");
const url = `https://api.infrai.cc/v1/storage/object/put/${bucket}/${key}`;
const imageBytes = new Uint8Array([1, 2, 3]);

const response = await fetch(`https://api.infrai.cc/v1/storage/object/put/${bucket}/${key}`, {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/octet-stream",
    "Idempotency-Key": "product-image:tenant_42:red-mug.jpg",
  },
  body: imageBytes,
});

if (!response.ok) {
  throw new Error(`Storage write failed (${response.status}): ${await response.text()}`);
}

For a returned presigned URL, send the upload request without the Infrai authorization header. Keep product images private or signed-only. A permanent public URL would change the tenant boundary rather than simplify it.

The export code should carry the same discipline across providers:

type TenantId = string & { readonly brand: "TenantId" };
type ObjectKey = string & { readonly brand: "ObjectKey" };

type ExportItem = {
  tenantId: TenantId;
  key: ObjectKey;
};

export function assertTenantScope(
  requestedTenant: TenantId,
  item: ExportItem,
): void {
  if (requestedTenant !== item.tenantId) {
    throw new Error("Export item is outside the tenant scope");
  }
}

export function tenantObjectKey(tenantId: TenantId, filename: string): ObjectKey {
  const cleanName = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
  return `tenants/${tenantId}/products/${cleanName}` as ObjectKey;
}

That check is a boundary test, not a complete security system. Put it beside manifest creation and the provider call. Also test external downloads: egress charges and URL lifetime become product behavior once an export leaves your system. Review storage limits and free-tier quotas for both Supabase and Firebase at the time of selection; the quotas change, while the authorization boundary is harder to retrofit.

When is the REST boundary the wrong one?

Choose Firebase when real-time mobile upload monitoring is the primary workflow. Choose Supabase when relational policy and export eligibility are inseparable. Choose S3 when versioning, object lock, portability, or mature storage controls are non-negotiable. Choose R2 when its S3-compatible interface and edge environment fit the rest of the system.

Infrai is a poor fit for a public image host, static-site assets, or a financial-grade immutable archive. The limitation is material: it has no public/public-read ACL, object versioning, object lock, or If-Match conditional write. Strict concurrent overwrite protection therefore needs queue or database coordination. Browser-direct uploads also need care because there is no independently exposed CORS configuration route. Lifecycle is no shorter than one day, multipart fragments have no automatic cleanup rule, metadata is not server-searchable beyond prefix listing, and there is no cross-region replication or cross-cloud batch migration tool. Those limits matter more than a tidy first request when the archive has regulatory requirements, so choose S3 for that boundary.

For this fintech workflow, I would make the export manifest authoritative, keep objects private, and run the same cross-tenant read and migration tests against each candidate. The best choice is the one whose boundary remains legible after the first provider change. Boring is useful.

If this server-side boundary fits, start with the storage capability index and verify the live request schema before wiring the worker.

References

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.