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

   ### SUMMARY
   
   In `raise_for_access`, the SQL Lab branch in `superset/security/manager.py` 
let `catalog_access` and `schema_access` short-circuit the per-table 
dataset-existence check. The chart-data branch right next door (`datasource` / 
`viz` / `query_context` path) requires `can_access_schema` on a registered 
`SqlaTable`, so the SQL Lab path was strictly broader than the chart-data path 
for the same permission.
   
   This PR tightens the SQL Lab path so every referenced table must resolve to 
a Superset dataset the user holds `datasource_access` on (or owns), bringing 
the two branches to the same effective scope.
   
   The table-only call sites (`/api/v1/database/<id>/table_metadata/`, 
`/select_star/`, `MetaDB`) keep the historical `catalog_access` / 
`schema_access` fallthrough since they return schema metadata only, not row 
data.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A. Backend permission scoping, no UI surface.
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest 
tests/integration_tests/security_tests.py::SupersetSecurityManagerTests -k 
raise_for_access
   ```
   
   Two existing tests (`test_raise_for_access_query`, 
`test_raise_for_access_sql`) were updated to mock 
`SqlaTable.query_datasources_by_name`, since the mocked permission check is now 
applied against a dataset. One new regression test 
(`test_raise_for_access_query_requires_dataset_match`) was added.
   
   ### ADDITIONAL INFORMATION
   
   #### Backwards compatibility
   
   Deployments that used `schema_access` as a deliberate "full SQL Lab access 
to one schema" grant will start being denied. Mitigation:
   
   - Upgrade those users to `database_access`, or
   - Register the relevant tables as Superset datasets so `datasource_access` 
can be granted explicitly.
   
   The chart-data path, `/table_metadata/`, `/select_star/`, and `MetaDB` are 
not affected.
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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