This guide explains when and how to select the appropriate tenant ID column for your Data Pool.
It covers when to use tenant IDs in Data Pools, how access control works with tenant IDs, how to select the appropriate tenant ID, and how to control access for your multi-tenant applications.
- When to use the Tenant ID in Data Pools
- How access control works with Tenant IDs
- How to select the appropriate Tenant ID column
- How to control access for your multi-tenant applications
- You have a Propel account.
When to use the Tenant ID in Data Pools
You should use the tenant ID feature when building multi-tenant applications. A multi-tenant application is a software application designed to be used and shared by multiple users or user groups, referred to as "tenants". These tenants can be organizations, business units, teams, or even individual users, each with their own data and configuration. Every B2B SaaS product or consumer app is a multi-tenant application.
Multi-tenant applications require additional access control capabilities because of two unique requirements:
- The tenants must only be able to access their own data.
- The application must support potentially millions of unique tenants.
How access control works with Tenant IDs
When creating a Data Pool, you can optionally specify a tenant ID. This is a pointer to a specific column which will be used to control access to the data. For example, a
customer_id column can be used as the tenant ID.
Once specified, you can then assign tenant-level access policies to your Metrics. When querying a Metric, Propel will only return values for a specific tenant. You specify the tenant ID when creating an access token. That way, the tenant ID is bound to the token and cannot be modified from client-side code.
How to select the appropriate Tenant ID column
The tenant ID should be your most granular identifier of tenancy in your application. It could be a
organization_id for B2B applications or a
user_id for consumer applications.
How to control access for your multi-tenant applications
To set up a Metric with a tenant-level access policy, follow the following steps:
- First, make sure you have a Data Pool with a tenant ID configured.
- Then, make sure you have an Application.
- With a Metric created on top of the tenant-aware Data Pool, select the Metric and choose the "Access Control" tab.
- Turn on the "Enable Access control for this Metric" option.
- In the Application drop-down menu on the left, select the Application you wish to enable access control for.
- In the right-hand policy drop-down menu, select "TENANT_ACCESS". The "ALL_ACCESS" option would grant access to all Metric data, not just data for the specified tenant.
Access tokens created against this Application now require a
tenant variable to be passed. If the
tenant passed matches the tenant ID specified on the Data Pool, data will be returned. See the Authentication guide for more details on access tokens.