gabotorresruiz opened a new pull request, #41753:
URL: https://github.com/apache/superset/pull/41753

   <!---
   Please write the PR title following the conventions at 
https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   Lets an **embedded guest** (an anonymous dashboard viewer authenticated by a 
guest token) read chart data over the MCP service, scoped to the dashboards in 
their guest token, so an embedded assistant can analyze the dashboard the 
viewer is looking at, and nothing else.
   
   Before this change a guest could read dashboard *structure* but 
`get_chart_data`, `get_chart_info`, and `get_chart_preview` failed ("Chart not 
found" / dataset not accessible): `ChartFilter` had no embedded-guest branch 
(only `DashboardAccessFilter` did), and the data path needs the embedded 
dashboard context for `raise_for_access`.
   
   **Design (mirrors the existing embedded-dashboard pattern, no new bespoke 
security path):**
   - **Resolution scoping lives in the access filter.** New shared helper 
`guest_embedded_dashboard_filter()` (`superset/utils/filters.py`) builds a 
SQLAlchemy condition matching the guest token's embedded dashboards, mirroring 
`DashboardAccessFilter`. `ChartFilter` gains a guest branch that scopes chart 
resolution to charts on those dashboards.
   - **Data-query authorization reuses core's existing guest `raise_for_access` 
branch.** New `superset/mcp_service/guest_scope.py` attaches the embedded 
dashboard context (`dashboardId` / `slice_id`) to the query, exactly as the 
embedded frontend does, and pins `slice_` so the guest payload tamper-guard   
(`query_context_modified`) still compares requested columns/metrics against the 
resolved chart. The three read tools skip the dataset RBAC pre-check for guests 
(guests read via the dashboard context, not dataset RBAC; `raise_for_access` 
remains the real gate).
   - **Contained to the embedded-guest path.** `guest_dashboard_id()` 
short-circuits on `is_guest_user()`, so behavior for regular authenticated 
users is unchanged.
   - Row-level security, dataset allow-list, and dashboard access continue to 
be enforced by core's `raise_for_access`; guests only reach their token's 
resources.
   
   This is the data-read scoping layer. The guest-token *authentication* that 
resolves the `GuestUser` over MCP lands in #41003, **this PR depends on 
#41003** for end-to-end function (the code is dormant until that merges; the 
diff itself is
   independent and reviews/merges standalone).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   N/A — backend-only change (MCP read-tool authorization); no UI
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   Requires `EMBEDDED_SUPERSET` and (for the guest to authenticate over MCP) 
`MCP_EMBEDDED_GUEST_AUTH_ENABLED` from #41003.
   
   1. Mint a guest token scoped to an embedded dashboard (e.g. via the 
guest-token endpoint) and present it as `Authorization: Bearer <guest_token>`.
   2. Call `get_chart_data` / `get_chart_info` / `get_chart_preview` for a 
chart **on** that dashboard --> returns the chart's data/metadata/preview.
   3. Call the same tools for a chart **not** on the token's dashboard --> not 
found (out of scope), with no leak.
   4. Confirm any RLS rules on the guest token still constrain returned rows.
   5. Confirm a regular authenticated (non-guest) user's results are unchanged 
(dataset access check still runs; no dashboard context attached).
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [x] Required feature flags: `EMBEDDED_SUPERSET`
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to