Creating Multi-Tenancy Tutorial
Introduction
In this tutorial, you will create two organizations. The first organization will be named California and the second will be named Washington.
- Each organization will have its own private folder structure where assigned users can access and share data sources, reports, dashboards, analyses, and related objects
- Anything stored in the organization’s folder structure is only accessible to its private members and superuser
You will also copy a Domain and Data Source from the sample Organization folder to the Public folder. Once configured for row-based security (explained in this tutorial), all users will have access to the Domain, but they will retrieve only their organization’s data.
Product Versions
This tutorial works with version 3.7 and later.
User
Administrator, DBA, Developer
Objectives
This guide will enable you to:
- Create Organizations
- Copy Resources to the Public Folder
- Update the Supermart Domain
- Set Row-Level Security for Public Domain
- Test with Ad Hoc Reports
Pre-Requisites
JasperServer must be installed with the Supermart demo environment in order to follow this tutorial
- You must have superuser access to JasperServer
- You must be able to stop JasperServer, modify an xml file, and restart the server
Before You Begin: Jaspersoft 3.7 only
JasperServer Pro 3.7.0 requires the following configuration change. This is not required in later versions. You need access to the application server in order to execute this step. (Reference bug 17284 fixed in Jaspersoft 3.7.0.1.)
<property name="applySecurityFilterInMemory" value="false"/>
|
Create Organizations
You will create organizations in this step. Organizations are the foundation for multi-tenancy. Each organization will then have its own private area for storing files and resources, which are completely hidden from other organizations.
Later in this tutorial you’ll see how organizationId, which is part of the logged in user’s “principal” authentication object, can be applied to objects stored in the shared Public area.
| Step | Action |
| 1 | Login as superuser/superuser. |
| 2 | From the Jaspersoft menu bar, choose Manage > Organizations. |
| 3 | With the [root] organization selected, click Add Organization, in the upper right corner. |
| 4 |
Enter California for the Organization Name. Enter ca for the Organization ID.
|
| 5 | Optional: This step is helpful for demonstration purposes.
|
| 6 |
Repeat steps 2 – 4 for the next organization:
Optional: Change the Full Names for jasperadmin to Washington Admin and joeuser to Washington User as in step 5 |
| 7 |
Results:
|
| 8 |
Log out. Log back in, but this time, enter:
|
| 9 |
Note:
http://localhost:8080/jasperserver-pro/login.html?showPasswordChange=nul...
http://localhost:8080/jasperserver-pro/login.html?showPasswordChange=nul...
http://localhost:8080/jasperserver-pro/ From the Jaspersoft main menu, click View > Repository.
|
Copy Resources to the Public Folder
The Jaspersoft Supermart demo includes a sample organization named Organization. Its organization/tenantId is organization_1.
You will copy resources from the sample organization to the Public area.
| Step | Action |
| 1 | Log back in as superuser/superuser.
|
| 2 | For this tutorial, we are going to create a folder to which all users can save reports.
|
| 3 |
|
| 4 |
Right-click Supermart Domain and click Copy.
|
| 5 | In the Folder view, click [root > Public]
|
| 6 | In the Folder view:
|
| 7 | In the Folder view, right-click [root > Public] and select Paste. |
Update the Supermart Domain
The Public folder should now contain Foodmart Data Source JNDI and Supermart Domain. Your objective now is to make sure the domain and its resources are all publicly available.
| Step | Action |
| 1 |
Right-click the Supermart Domain and click Edit. Result: The Edit Domain designer opens.
|
| 2 |
In the Data Source box, click Browse.
|
| 3 | Select [Public > Foodmart Data Source JNDI] and click OK. |
| 4 |
Click Save. Result: All users can now create Ad Hoc queries, charts, tables, and crosstabs using this Domain. |
Set Row-Level Security for Public Domain
Now you will activate domain-based security, and edit an XML file in a plain text editor.
Note: Don’t worry if you’re not yet comfortable with the expression language. This is an introductory tutorial for an advanced feature. For now, you can simply focus on the mechanics and the outcome.
| Step | Action |
| 1 | At the top of the page, click Resources, which is located below the main menu and to the right of Edit Domain.
|
| 2 |
Under Security File, select supermartDomain_security and click Download. |
| 3 |
|
| 4 | Open supermartDomain_security.xml in a plain text editor. |
| 5 | Locate the Access Grant definitions for Sales, Inventory, Expenses, and Employees.
|
| 6 |
|
| 7 |
|
| 8 |
|
Test with Ad Hoc Reports
Here you test row-based filtering based on the logged-in user’s organization/tenantId.
| Step | Action |
| 1 | Log out and log back in as a California user (see Step 1.8):
|
| 2 | From the Jaspersoft main menu, click Create > Ad Hoc Report. |
| 3 | Click the Domains tab and then:
|
| 4 | Create the query:
|
| 5 |
Design the report:
|
| 6 |
|
| 7 | Log out and log back in as a Washington user (see Step 1.8):
|
| 8 |
|
What's Next?
Consider your entire community when applying security filters to public objects.
Example: If you log in as an organization_1 sample user, you will retrieve no data when accessing this sample domain. This is because the user’s tenant_id, organization_1, does not match any value in store_state. You can adjust for this programmatically in the <principalExpression> section preceding the <filterExpression>.
In our sample, we adjusted for superuser in the principalExpression, essentially skipping the filter when tenantId is empty (which is the case when you log in as superuser).
Valuable reference materials include:
- JasperServer User Guide, Release 3.7: Section 7 Advanced Domain Features, particularly section 7.4 The Domain Security File
- This guide is included with JasperServer Pro in the /docs folder.
- This guide is included with JasperServer Pro in the /docs folder.
- JasperServer Ultimate Guide, Release 3.5: Section 6 Securing Data in a Domain
- Jaspersoft subscribers can download this guide from the Jaspersoft Support Portal
- It is also for sale at http://www.jaspersoft.com.
- Note: The JasperServer Ultimate Guide for Release 3.7 is expected in March 2010.
- Jaspersoft subscribers can download this guide from the Jaspersoft Support Portal
Written By
This tutorial was written by Mary Flynn, Senior Sales Engineer, February 2010.
Language







