Question

What is the access control for Superset schema.table?

Answer and Explanation

In Apache Superset, access control for a specific schema.table is managed through a combination of roles and permissions. It's important to understand how these are configured to properly secure your data and visualizations. Here’s a breakdown of how access control works for schema.table:

1. Roles:

- Superset uses roles to group permissions. Roles can be assigned to users, and a user can have multiple roles. Examples include "Admin," "Viewer," "SQL Lab User," or custom roles like "Sales Team Data Access."

2. Permissions:

- Permissions grant specific access to resources within Superset. These permissions are associated with roles. For schema.table access, key permissions include:

- "can_read" on `schema.table` : This permission enables users to query data from a specific table. If a user has this permission on public.users , they can run SELECT statements against that table.

- "can_write" on `schema.table`: This permission would theoretically allow write operations such as UPDATE or DELETE on the table, however, Superset mainly focuses on data visualization and read-only access, thus write permissions are usually less relevant directly on a table.

- "datasource access" on `schema.table`: This permission manages whether the user has the ability to see the datasource in the Superset UI. Even if they have "can_read" on the table, if they do not have datasource access, they won't be able to see it in the UI to create charts.

-"all_datasource_access": This grants access to all datasources. Care should be taken to limit its usage.

- It is crucial to understand that access to the database is also dependent on the database user configured for the connection within Superset and its associated database rights on that schema or table.

3. How Access Control is Implemented:

- Database Level: The Superset database connection settings are crucial. The database user configured for Superset needs read (and potentially other) permissions granted to it in the underlying database for the schemas and tables it will query. This setup is outside of Superset’s direct control and is part of database administration.

- Superset UI: Access control within Superset is managed through its UI in the “Security” menu. You must ensure that the relevant roles are created and that the necessary permissions (like can_read or datasource access) are granted to those roles. Subsequently, users must be assigned the roles appropriate for their access requirements. You would then navigate to Roles->Edit Permissions and select the desired table, then assign "can_read" permission to the table.

- Data Source Definition: When you add a data source to Superset (pointing to schema.table), permissions are then layered on top through roles. If the data source isn't accessible, even with a valid database user setup, users won't see it or query it through Superset.

4. Example Scenario:

- Suppose you have a table named public.sales_data. You want to grant read-only access to your sales team.

- First, in your database ensure that the Superset user has proper SELECT permissions for public.sales_data.

- Then, within Superset, create a role, for example: "SalesTeamRole,".

- Grant "can_read" and "datasource access" permissions on the specific table public.sales_data to the "SalesTeamRole".

- Assign the users in your sales team to the "SalesTeamRole."

- Now, only users with the "SalesTeamRole" can read data from public.sales_data through Superset.

5. Best Practices:

- Follow the principle of least privilege: only grant the minimum permissions needed.

- Use roles effectively to manage access for groups of users, not individual users.

- Regularly review and update permissions as team structures and data access needs change.

By understanding and applying these principles, you can effectively manage access control for schema.table in Apache Superset, ensuring your data is both accessible and secure.

More questions