fix(embedded): resolve guest user permissions in user_view_menu_names#39197
fix(embedded): resolve guest user permissions in user_view_menu_names#39197gerbermichi wants to merge 1 commit intoapache:masterfrom
Conversation
Guest users (embedded dashboards via guest tokens) have is_anonymous=False but no database identity (user_id is None). The existing code path for authenticated users queries the assoc_user_role table by user_id, which returns nothing for guests. This caused all datasource_access, database_access, and schema_access permissions on the guest role to be invisible, breaking features like chart-based annotation layers that rely on ChartDAO.find_by_id (which applies a datasource access filter via ChartFilter). Fix: detect guest users before the authenticated user path and resolve permissions directly from the roles attached to the guest token.
Code Review Agent Run #78326eActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #39197 +/- ##
=======================================
Coverage 64.47% 64.47%
=======================================
Files 2541 2541
Lines 131669 131675 +6
Branches 30523 30525 +2
=======================================
+ Hits 84893 84897 +4
- Misses 45310 45311 +1
- Partials 1466 1467 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Guest users (embedded dashboards via guest tokens) have is_anonymous=False but no database identity (user_id is None). The existing code path for authenticated users queries the assoc_user_role table by user_id, which returns nothing for guests. This caused all datasource_access, database_access, and schema_access permissions on the guest role to be invisible, breaking features like chart-based annotation layers that rely on ChartDAO.find_by_id (which applies a datasource access filter via ChartFilter).
Fix: detect guest users before the authenticated user path and resolve permissions directly from the roles attached to the guest token.
SUMMARY
user_view_menu_names()inSupersetSecurityManagerwas broken for guest users (embedded dashboards via guest tokens). Guest users haveis_anonymous=Falsebut no database identity (user_idisNone). The authenticated user code path queries theassoc_user_roletable byuser_id, which producesWHERE user_id IS NULL— matching nothing.This caused all role-based permissions (
datasource_access,database_access,schema_access) to be invisible to guest users, even when correctly assigned to the guest role. Any code path usinguser_view_menu_names()was affected, most notablyChartFilter(viaget_dataset_access_filters), which broke chart-based annotation layers on embedded dashboards with a misleading"Chart not found" error.
Fix: Add a guest user check before the authenticated user path that resolves permissions directly from the roles attached to the guest token, using the same pattern as the existing anonymous user path.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: Charts with annotation layers on embedded dashboards fail with:
Chart with ID (referenced by annotation layer '') was not found.
Please verify that the chart exists and is accessible.
After: Annotation layers load correctly because
ChartDAO.find_by_id()can now see the guest role's datasource permissions throughChartFilter.TESTING INSTRUCTIONS
datasource_accessfor Chart A's datasource to the Public role (or whichever role is configured viaGUEST_ROLE_NAME)ADDITIONAL INFORMATION