As data-driven organizations scale, the need for secure, granular access control in visualization platforms becomes critical. Apache Superset is a powerful, modern data exploration and visualization platform, but out of the box, it treats all users with standard RBAC roles. For multi-tenant environments—such as SaaS providers serving different clients or enterprises with distinct regional teams—you need more than just "can view" or "can edit" permissions. You need Row-Level Security (RLS) combined with secure identity management via Single Sign-On (SSO).
This guide walks intermediate to advanced developers through the practical implementation of these features to ensure data isolation and centralized authentication.
Understanding the Architecture
Superset’s security model is built around roles and permissions. RLS allows you to restrict which rows of data a user can see within a specific dataset. SSO integrates Superset with your corporate identity provider (like Keycloak, Okta, or Azure AD) to manage authentication externally, reducing password sprawl and improving security posture.
Configuring Single Sign-On (SSO)
Superset supports various SSO protocols, with OpenID Connect (OIDC) being the most common. To implement SSO, you must configure the superset_config.py file. Below is a practical example using an OIDC provider.
# superset_config.py
AUTH_TYPE = "oid"
OAUTH_REMOTE_APP = {
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"auth_uri": "https://your-idp.example.com/auth",
"token_uri": "https://your-idp.example.com/token",
"api_base_url": "https://your-idp.example.com/",
"userinfo_uri": "https://your-idp.example.com/userinfo",
"request_token_params": {},
"access_token_params": {},
"authorize_params": {"scope": "openid profile email"},
"client_kwargs": {"verify_ssl": True},
}
# Map external groups to Superset roles
OAUTH_TO_ROLE = {
"admin-group": "Admin",
"analyst-group": "Alpha", # 'Alpha' is a role you create in Superset
"viewer-group": "Public",
}
After setting this, restart your Superset instance. Users will now be redirected to your IdP for login, and their Superset roles will be automatically assigned based on their group membership in the IdP.
Implementing Row-Level Security (RLS)
RLS is the core of multi-tenant data isolation. It allows you to define SQL filters that are applied to queries based on user attributes. In Superset, RLS rules are defined in the UI, but they can also be managed programmatically for consistency in CI/CD pipelines.
Let’s assume we have a sales table with a region column. We want the alpha role to only see data from the 'US' region.
1. Navigate to Databases > Select Database > Row Level Security.
2. Create a new rule with the following settings:
- Role: Select
Alpha. - Dataset: Select your
salesdataset. - Filter SQL Expression:
region = 'US'
For dynamic, user-specific RLS (e.g., users can only see their own department’s data), you can leverage Jinja2 templating in the filter expression to access user attributes passed from your SSO provider or custom headers.
# Example Dynamic RLS Filter
# Assumes 'department' is extracted from the user's JWT or profile
{{ current_user.attributes.get('department', 'unknown') }}
Best Practices for Multi-Tenant Environments
- Role Separation: Create distinct Superset roles for each tenant or department (e.g.,
Tenant_A_Verified,Tenant_B_Verified). Do not rely on a single generic "User" role. - Test RLS Extensively: Always validate RLS rules in a staging environment. A misconfigured filter can lead to data leakage or empty dashboards.
- Use SSO Group Mapping: Automate role assignment via SSO group mapping to avoid manual admin errors when onboarding new users.
- Audit Logs: Enable Superset’s audit logging to track who accessed which datasets, helping with compliance and security forensics.
Conclusion
Implementing Row-Level Security and SSO in Apache Superset transforms it from a simple BI tool into a robust, enterprise-grade analytics platform. By decoupling authentication to an external IdP and applying granular data filtering at the database level, you ensure that each user sees only the data they are authorized to view. This approach not only enhances security but also simplifies user management in complex, multi-tenant environments.
Start by configuring your SSO integration, then layer on RLS rules for your most sensitive datasets. With these two pillars in place, your Superset instance is ready to scale securely with your organization.