Achieving Multi-Tenancy on Data Analytics With Cumul.io and Auth0
This article is a tutorial that runs through a demo project designed to achieve multi-tenancy on integrated analytics platforms using Cumul.io and Auth0.
Join the DZone community and get the full member experience.Join For Free
Often, companies will have a data analytics tool to follow up on various metrics such as ARR, KPI, or internal statistics on performance, or they want to offer these types of insights to their clients or platform users. And the list can go on! And in many cases, you get into a situation where you want to make sure anyone accessing our data analytics tools can only see data that they should be allowed to see or data that's only related to themselves. This is where multi-tenancy comes in. In this tutorial, we will walk through how to configure your Cumul.io dashboard with multi-tenancy based on user information on login, which we manage with Auth0. Before we dive into the specifics, let me give you some context on what these two platforms are used for;
Cumul.io: SaaS that allows you to create your own data insight and analytics dashboards that you can easily integrate and embed within your own platform.
Auth0: A flexible solution to add authentication and authorization services to your application. You can connect any application to Auth0 and define how you want your users to log in.
You can either clone this repo and follow the steps exactly, or you could take this as a guide for your own setup. The repository already implements a simple single-page web app that has an integrated dashboard that you can run locally. To be able to follow these steps you will need a Cumul.io account (Free trials are available here) and an Auth0 account.
Why Set up Multi-tenancy on Your Dashboard?
Multi-tenancy on your dashboard gives you the freedom of deciding who sees what when they visit it. It lets you decide for example what an internal user may see (such as an employee) or what an end-user may see.
Assume you have a company that owns various products and you want to see how sales are going for each product. You want to have a dashboard that displays this but you don't want all employees to see all products, rather the one related to their department. This is only one simple example of why you would want user-based filtering. It is so that you can make sure an end-user only gets to see what's intended for them.
Our aim in this tutorial will be to get our imaginary employees Angelina and Brad to go from seeing this:
Step 1: Create a Dashboard
The first step, log into your Cumul.io account and create a new dashboard (we've named ours 'Multi-Tenancy Demo'). In this example, we use the 'United Widgets Sales' dataset, which you can find at: DATA > (+) > Demo Data > United Widgets Sales > Import.
We have selected a grouped line chart and have used the Month in Datetime for the X-axis, the Amount for the Measure and grouped by Product name to obtain the following:
Step 3: Add Dashboard to Web App
Once you apply this new filter, the chart you see on your Cumul.io dashboard will display data only for product names that are included in the department parameter, and nothing if you haven't added any values to the parameter.
Now you're all set! You can run
npm run start and go to
localhost:3000 on a browser. Once you login as one of your users you will see that they can only see data related to their department.
Step 6: Add Extra Metadata (Optional)
Now that you've filtered your dashboard depending on what department your employee works on, let's walk through what you can do to add something else if you want to. This section is a summary of steps you will need to take and can be adjusted as you wish.
Assume you don't only want to filter based on department, but you also want to filter a dashboard based on an employee's date of employment. For some reason, let's say you don't want an employee to see sales data from before they joined. Here's what you can do:
- Let's add a 'join_date' field to our users' app_metadata on Auth0. For example:
- Add join_date as metadata to send to cumul.io in server.js:
Create a join_date parameter of type Datetime on Cumul.io (We've selected 1 September 2017 as the default value):
- Add a filter to your dashboard that filters dates greater than join_date and Apply
npm run startand go to
When you login as Angelina, for example, you now only see sales data for dates on and before her join_date (1 Nov 2019):
NOTE: At this point as your code is expecting a join_date field from the metadata it's receiving from Auth0, you will have to add the same field in other users' app_metadata.
You are all set and now should have a working web app with an integrated multi-tenant dashboard! Finally, here are some useful resources to conclude:
Some Useful Resources
- The example repo we use here: cumulio-auth0.
- Integration blog and video: How to integrate Dashboards Securely.
- Developer documentation: Dashboard Integration.
- On Parameters and Filters: Parameterizable Filters.
- Webinar on Parameters: How to use parameters.
Published at DZone with permission of Tuana Çelik. See the original article here.
Opinions expressed by DZone contributors are their own.