Multi-Tenant Data Isolation and Permissions

Overview

Summary

In a multi-tenant application, every customer shares the same software but must never see each other's data, so data isolation and permissions need to be designed and tested from the start.

Most SaaS and B2B platforms serve all customers from one application and database. Each customer, or tenant, has its own users and data, separated by rules in the code and database. A single missing check can expose one customer's data to another.

Within each tenant, role-based permissions decide what each user can see and do: administrators, managers, and regular users, for example.

Warning Signs

  • You are building a platform that several companies will use.
  • You are adding business customers to an app built for individuals.
  • Permissions are handled screen by screen with no central rules.
  • You are not certain one customer can never see another's data.

Recommended Actions

  • Choose an isolation model: shared database with tenant IDs, separate schemas, or separate databases.
  • Enforce tenant filtering centrally, not in each query by hand.
  • Define roles and permissions in one place and check them on the server.
  • Write automated tests that try to cross tenant boundaries.
  • Log access so any problem can be traced.

Detailed Guidance

Choosing an isolation model

A shared database with a tenant ID on each row is simplest and cheapest. Separate databases per tenant give stronger isolation and suit customers with strict requirements, at higher cost. Many platforms mix the two.

Central enforcement

Relying on every developer to remember a tenant filter in every query guarantees a mistake eventually. Global query filters or database row-level security enforce it everywhere.

Permissions inside each tenant

Define permissions as actions, such as viewing invoices or managing users, assigned to roles, so new features fit into the model instead of adding special cases.

Frequently Asked Questions

Answers

  • How do you keep each customer's data separate?

    With a tenant identifier on every record, enforced centrally in the data layer, and automated tests that try to access another tenant's data.

  • Should each customer have its own database?

    Only if they need it for compliance or size. A shared database with central isolation suits most platforms.

  • Can we add role-based permissions to an existing app?

    Yes. Permissions are defined centrally, checked on the server, and applied to existing features.

Why Moosara Can Help

How We Help

Moosara builds multi-tenant platforms on .NET and SQL Server with tenant isolation enforced centrally, role-based permissions checked on the server, and automated tests that prove customers cannot see each other's data.

Request a Free Consultation

Related Guides