Overriding can_access_datasource to block access to sensitive tables #35932
Replies: 1 comment 2 replies
-
|
Hi @gabriel-korbato! I'm Dosu and I’m helping the superset team. Overriding To enforce restrictions, make sure roles do not have If you need strict per-dataset or per-chart visibility, you may need to add custom filtering logic or handle unauthorized chart hiding on the frontend for now. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Superset's permissions are set up in a way that if a user has access to a data source, they have implicit access to the database. This makes sense in many cases, but my database has a set of tables that contain sensitive data that only privileged users should be able to access, make charts from, or see charts from. The list of tables with sensitive data is large and growing each day, so it is not practical to set row-level permissions, because this requires listing each table.
I started browsing the code for
SupersetSecurityManager, since I had to make a subclass of that for other security matters, found thecan_access_datasourcefunction, and overrode it insuperset_config.pywith additional logic that checks the table name and the user's roles to determine if they should have access. I tested this with log statements and verified that the function correctly returnsTrueorFalseas required: when an unprivileged user accesses a chart that has adatasourcethat should be privileged, the function returns False, and when a privileged user accesses the same chart, the function returns True.So far so good, but I am stuck because Superset displays the chart fed from the datasource anyway. Does anyone know what I am missing?
Beta Was this translation helpful? Give feedback.
All reactions