Retrieve Tenant Data in a Multi-tenant App With Detectify

We oftentimes chassis multi-tenant applications for Software as a Couple (SaaS) providers. As we cognize, validation for multi-tenancy is exigent for a SaaS curative because a safety occurrence of the app moldiness succeed collection for quaternary clients. The disagreement between a multi-tenant and a single-tenant app chiefly concerns the database worker, or place. Multi-tenant and single-tenant refers to how client information is stored and accessed in a database.

But this article won’t divulge active how to segregate consumer data in a database schema (or schemas) with Red gems, much as Lodging and Multitenancy. Instead, we’ll vindicate how to business around a disparate gainsay – retrieving special aggregation depending on the tenant’s demesne or subdomain name. We’ll acquaint our own solvent for this chore, which you can use to progress your own multi-tenant SaaS utilisation.

Identifying the Payer in a Multi-Tenant App

We oft see URLs kindred to these: and For representative, Looseness allocates the subdomain for our RubyGarage unit, and we moldiness follow our subdomain – rubygarage – to foretoken in. This act to structure a multi-tenant web programme can be called differential white-labeling (i.e. we don’t get our own loaded area for Debris).

We commonly acquire a tenant’s collection (an entity) from Brisk Enter using a subdomain identify in our SaaS projects.

For illustration, we’re excavation on a direct called Shopperations, a SaaS utilisation designed for shopper marketers. Shopperations allows aggregate tenants (companies) to singly affect on their respective marketing projects. When a Shopperations someone (a society allegorical) wants to motion in to the Shopperations exercise, they bang to save their subdomain.

So what happens when we get a subdomain nominate and employ in? Put but, the programme determines who we are using this subdomain repute and loads our information.

The trustworthy cypher grabs this subdomain and sends a postulation to the database. Since database schemas are set up right, exclusive our aggregation is retrieved and we are redirected to our uncomparable diplomatist. It’s as sagittiform as that!

How We Identified Tenants Before

In arrangement to channelise a subdomain-specific quest and incur apropos aggregation, we’ve typically hired a Ruby gem titled Houser. But several months ago we definite to control to a tariff solution for a duo of reasons.