Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Isolate templates and assets by resolving a trusted tenant and user context immediately after authentication, then carrying that context through every template lookup, database query, storage key, download, cache entry, and background job. A tenant directory or object prefix improves organization, but it is not authorization: every read and write must independently verify ownership.

What “per-user isolation” must protect

There are usually two boundaries to enforce:

  • Tenant boundary: one organization must not read another organization’s records, templates, or files.
  • User boundary: users inside the same tenant may need different permissions for private uploads, drafts, or personal assets.

Resolve both identities on the server from a session, validated JWT claims, or a trusted host-to-tenant mapping. Never trust a tenant ID, user ID, filename, URL path, or object prefix supplied by the browser. Use the resolved context before rendering a template, querying a model, constructing an object key, generating a signed URL, or starting a background task.

A useful invariant is: every tenant-owned operation has an authorization decision tied to the server-resolved tenant and, where applicable, user. The path or key is only an identifier; possession of a plausible-looking key is not proof of permission.

Choose an isolation model deliberately

Multitenant applications generally use one of three database layouts. The right choice depends on regulatory requirements, operational capacity, migration tooling, backup scope, and the impact of a coding mistake.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Model Isolation boundary Operational profile Primary risk or cost
Separate database per tenant Database instance or logical database Tenant-level backup, restore, and deletion are straightforward. Provisioning, migrations, connection management, and monitoring multiply with tenant count.
Separate schema per tenant Namespace inside one database One database with clear namespace separation; django-tenants documents this as a compromise between simplicity and performance and implements schema-per-tenant. Schema migrations, connection routing, and cross-tenant reporting require deliberate tooling.
Shared schema with tenant key Application- and query-level row scope Usually the easiest model to operate at scale and the most efficient for shared infrastructure. A missed filter, uniqueness rule, cache key, job argument, or storage lookup can disclose another tenant’s data.

Use the strongest boundary justified by your threat model, contracts, and regulation. A shared schema can be safe, but only when tenant scope is systematic and preferably reinforced with database row-level policies where your database supports them.

Make tenant scope part of data design

Every tenant-owned table should have a non-null tenant key. Add composite uniqueness constraints such as (tenant_id, slug) rather than a global slug constraint. Include tenant scope in foreign-key validation, search indexes, cache keys, event payloads, and job identifiers. A background worker must receive a tenant ID as data, resolve it, and apply the same authorization rules as an HTTP request.

Resolve context before any lookup

  1. Authenticate: validate the session or token and identify the user.
  2. Resolve the tenant: use a server-maintained membership relation or a trusted hostname mapping. If a user belongs to several tenants, require an explicit, authorized tenant selection.
  3. Attach an immutable request context: keep tenant_id and user_id in a request-scoped object rather than repeatedly accepting them from controller parameters.
  4. Authorize the action: check role, ownership, and object state before querying or issuing a download.
  5. Pass context downstream: include tenant and user IDs in service calls, cache namespaces, asynchronous jobs, audit records, and storage operations.

Reject missing, ambiguous, or conflicting context with a non-disclosing response. Do not fall back to a global tenant, an administrator’s tenant, or a client-provided default.

Enforce database scope on every path

In a shared schema, scope at the data-access layer so individual views cannot accidentally omit the predicate. A minimal Django-style pattern is:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from django.core.exceptions import PermissionDenied
from .models import Asset

def get_asset_for_request(request, asset_id):
    tenant_id = request.tenant.id
    user_id = request.user.id

    asset = (Asset.objects
             .filter(id=asset_id, tenant_id=tenant_id)
             .first())
    if asset is None:
        raise PermissionDenied("Asset is not available")

    if not asset.is_shared and asset.owner_id != user_id:
        raise PermissionDenied("Asset is not available")
    return asset

Apply the same rule to list, detail, update, delete, export, preview, and admin endpoints. Avoid fetching by a globally unique object ID and checking tenant ownership later if the initial query can already include the tenant predicate. For operations that join tables, scope both sides or rely on constrained foreign keys and an authorization check.

Defense in depth

  • Use database row-level policies where available to reject cross-tenant rows even if application code misses a filter.
  • Give reporting and maintenance jobs explicit tenant scopes; prohibit unscoped ORM queries in production code review.
  • Namespace cache keys, for example tenant:{tenant_id}:template:{template_id}, and invalidate by tenant.
  • Record user, tenant, object ID, action, and allow/deny decision in audit logs. Do not log raw secrets or signed URLs.

Tenant-aware template loading

Keep shared templates as a fallback, and search a tenant-specific location first. The django-tenants file-handling guide describes a tenant-aware loader that “look[s] for the tenant-specific templates first, before reverting to the standard search path.” This permits a tenant to override branding or a page fragment without copying the entire application theme.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Recommended directory shape

templates/
  shared/
    base.html
    invoices/detail.html
  tenants/
    tenant_42/
      base.html
      invoices/detail.html

Construct the tenant directory from the server-resolved identifier, not from a request parameter. Keep the shared fallback intentionally safe: it should not contain tenant secrets or private data. Pass tenant-specific values as context after authorization; a template path alone must never be used to decide whether a user can view a record.

Django configuration pattern

Configure the tenant-aware loader ahead of the ordinary search path so an override wins while the shared loader remains available. The exact setting names depend on the loader and package version you use; follow the installed django-tenants documentation and test that an unknown tenant cannot make the loader traverse another tenant’s directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scope static files and user media separately

Static build output (compiled CSS, JavaScript, fonts, and public images) and user media (uploads, exports, invoices, and private previews) have different security policies.

Content Suggested location Delivery policy
Shared static assets static/ or a public bucket/prefix Public or CDN-cached; never place secrets here.
Tenant-branded static overrides static/tenants/{tenant_id}/ Public only if the branding is intentionally public and the prefix policy is limited.
Private user uploads media/tenants/{tenant_id}/users/{user_id}/ Private origin; authorize first, then issue a short-lived signed URL or stream through an authorized endpoint.

django-tenants documents tenant-aware static and media handlers. Its default behavior is to create a tenant subdirectory in STATIC_ROOT and another in MEDIA_ROOT. Use immutable object IDs in names to avoid collisions and filename guessing:

tenants/{tenant_id}/users/{user_id}/assets/{asset_id}

Do not use the original filename as an authorization mechanism. Store the original name as metadata, sanitize it for display, and generate the storage key server-side.

Object-storage policies that add a second boundary

Application checks should remain mandatory, but object storage can enforce additional conditions. AWS’s sample architecture describes tagging objects by tenant and user and using an access point per tenant. Oracle security guidance describes policies constrained by bucket and object-name patterns plus conditions for a specific user. These controls can be combined with short-lived credentials and immutable object IDs.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Safe download sequence

  1. Resolve the authenticated tenant and user.
  2. Look up the asset with both the asset ID and tenant ID.
  3. Check ownership or a tenant-approved sharing rule.
  4. Construct or retrieve the expected immutable object key; ignore a client-supplied key.
  5. Issue a short-lived signed URL, or proxy the download through a private origin.
  6. Audit the decision and object ID.

Keep private buckets and prefixes private by default. If you use a CDN, configure it to authenticate to the private origin rather than making the origin publicly readable.

Keeping public static files from exposing private media

A common mistake is placing static/ and media/ in one bucket and enabling a bucket-wide public-read setting. Cookiecutter Django’s storage guidance warns that this can expose both prefixes. Use a separate public container for static files, or apply a stored access policy that makes only the static prefix public. Keep signed-query authentication enabled for private media, or put a CDN in front of a private origin with an origin-access control equivalent.

Also check indirect leaks: directory listings, predictable download URLs, overly long cache lifetimes, image thumbnails generated into a public path, and error pages that echo object keys.

Testing the negative cases

Isolation is proven by denial tests, not by directory names. For each endpoint and storage operation, authenticate as user A and independently change:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • the user ID;
  • the tenant host or selected tenant;
  • the URL path and object ID;
  • the object key or filename;
  • the signed download token;
  • the background-job tenant argument.

Each unauthorized variant should be denied without revealing whether the other tenant’s object exists. Test list endpoints, previews, thumbnails, exports, template overrides, cache hits, and retry paths. Run these checks after migrations and whenever authorization or storage code changes.

Performance, reliability, and cost trade-offs

Database and application overhead

Shared-schema filtering adds predicates and index requirements; index tenant keys together with common lookup columns. Schema-per-tenant adds routing and migration work. Database-per-tenant increases connection and provisioning overhead but narrows backup and failure scope. Measure connection limits, migration duration, backup windows, and noisy-neighbor behavior against your tenant distribution rather than choosing by habit.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Storage and delivery

Tenant prefixes make lifecycle rules, quotas, and deletion jobs easier. Keep object IDs immutable so retries are idempotent. Generate signed URLs only after authorization and give them the shortest useful lifetime. Separate public caching from private caching; a shared CDN cache key must never allow one tenant’s response to satisfy another tenant’s request.

Failure handling

Fail closed when tenant resolution, policy evaluation, or storage authorization is unavailable. Do not serve a shared fallback page containing tenant data. Make asynchronous cleanup and migration jobs resumable and tenant-scoped, and alert on authorization-denied spikes without exposing object contents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

When you need a rendered tenant page for QA, documentation, or a visual regression check, ScreenshotNeo is a website screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP, or PDF. Before capture it can accept the cookie/consent banner and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

One request is enough (see the ScreenshotNeo API documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

For protected previews, configure custom headers, cookies, an Authorization value, user agent, timezone, or geolocation. Other relevant controls include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper size/margins/landscape/page ranges, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector or network-idle waits, blocked ads/trackers/requests/resource types, resizing, selectable cache TTL, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 shots per month with no card. Paid plans are Starter $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000; yearly billing gives two months free, and every feature is on every plan. Sign up for the free plan to start without a card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common failure modes and fixes

A tenant sees the shared template instead of its override

Verify the tenant-aware loader is ordered before the shared loader, the resolved tenant ID matches the directory, and the deployment collected the override into the location searched at runtime. Clear template caches after changing the loader configuration.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

A user can guess another user’s download URL

Move authorization before URL generation, query by tenant and asset ID together, and replace predictable filenames with immutable IDs. Revoke or shorten existing signed URLs if a policy change requires immediate protection.

Private media is visible through a public bucket

Inspect bucket-level and prefix-level policies, CDN origin access, generated thumbnails, and cache headers. Put media in a separate private container when a precise prefix policy is difficult to guarantee.

Background jobs cross tenant boundaries

Include tenant ID in the job payload, validate that the referenced object belongs to it, and prevent workers from accepting an unscoped “process all” operation in request-triggered paths.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cache returns another tenant’s page or asset

Add tenant and user dimensions to cache keys where content is private, and configure CDN cache policies so authorization headers and signed parameters are handled deliberately. Purge keys after tenant deletion or branding changes.

FAQ

Should the tenant ID be part of the URL?

It may help routing and debugging, but it must not be trusted as the authorization decision. Compare it with the server-resolved membership and reject mismatches.

Can tenants share a template safely?

Yes. Keep shared templates read-only and free of tenant data, then inject authorized tenant context at render time. Tenant overrides should inherit from that controlled shared base.

When should media be public?

Only when the business requirement makes public access intentional. User uploads, exports, and previews should remain private and be delivered through an authorized stream or short-lived signed URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a storage prefix enough for compliance?

No. Prefixes organize objects; application authorization and storage policies enforce access. Use both, plus denial testing and audit records.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.