Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dataset name change and permission change #21161

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Aug 23, 2022

SUMMARY

Currently updating a dataset does not update or delete any associated permissions.
Dataset updates impact data permission names on table_name, database and schema.

Dataset updates on the affected fields will cut user access to charts that are based on the dataset. This particularly impacts virtual datasets.

Also took the chance to refactor (split) set_perm to multiple SQLAlchemy events:
dataset_after_insert
dataset_after_update
dataset_after_delete
database_after_insert
database_after_update
database_after_delete

This makes:

  • Reasoning around data permissions easier
  • Avoids having to infer model types to take different behaviours
  • Makes it easier to just update permissions on certain field changes (improving performance)

Related previous fix: #20081

Examples:
Creating a database named db1 with 2 datasources named: (ds1, ds2), creates the following permissions:

database_access -> [db1](id:1)
datasource_access -> [db1].[ds1](id:1)
datasource_access -> [db1].[ds2](id:2)

And a chart based on ds1 would have Chart.perm field equal to datasource_access -> [db1].[ds1](id:1)

Changing datasource name ds1 to ds1_changed, would leave the permissions on the following state:

database_access -> [db1](id:1)
datasource_access -> [db1].[ds1_changed](id:1)
datasource_access -> [db1].[ds2](id:2)

But the Chart.perm field would be the same, so a virtual dataset name change would remove access to all related charts and dashboards to users without the all datasource permission

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov
Copy link

codecov bot commented Aug 26, 2022

Codecov Report

Merging #21161 (0fdcfa9) into master (756ed0e) will decrease coverage by 11.25%.
The diff coverage is 57.32%.

❗ Current head 0fdcfa9 differs from pull request most recent head 678589e. Consider uploading reports for the commit 678589e to get more accurate results

@@             Coverage Diff             @@
##           master   #21161       +/-   ##
===========================================
- Coverage   66.29%   55.03%   -11.26%     
===========================================
  Files        1773     1784       +11     
  Lines       67680    68232      +552     
  Branches     7214     7265       +51     
===========================================
- Hits        44866    37550     -7316     
- Misses      20971    28813     +7842     
- Partials     1843     1869       +26     
Flag Coverage Δ
hive 52.99% <41.77%> (-0.18%) ⬇️
mysql ?
presto 52.89% <43.80%> (-0.18%) ⬇️
python 57.74% <51.57%> (-23.70%) ⬇️
sqlite ?
unit 50.75% <47.87%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...packages/superset-ui-core/src/query/types/Query.ts 100.00% <ø> (ø)
...gins/legacy-plugin-chart-world-map/src/WorldMap.js 0.00% <0.00%> (ø)
...egacy-plugin-chart-world-map/src/transformProps.js 0.00% <0.00%> (ø)
...lugin-chart-echarts/src/BigNumber/BigNumberViz.tsx 0.00% <ø> (ø)
...BigNumber/BigNumberWithTrendline/transformProps.ts 46.26% <ø> (ø)
...ns/plugin-chart-echarts/src/Gauge/EchartsGauge.tsx 0.00% <0.00%> (ø)
...ns/plugin-chart-echarts/src/Graph/EchartsGraph.tsx 0.00% <0.00%> (ø)
...nd/plugins/plugin-chart-echarts/src/Graph/types.ts 100.00% <ø> (ø)
...rts/src/MixedTimeseries/EchartsMixedTimeseries.tsx 0.00% <0.00%> (ø)
...hart-echarts/src/MixedTimeseries/transformProps.ts 0.00% <0.00%> (ø)
... and 424 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dpgaspar dpgaspar requested a review from geido August 30, 2022 08:54
@dpgaspar dpgaspar changed the title [WiP] fix: dataset name change and permission change fix: dataset name change and permission change Aug 30, 2022
@dpgaspar dpgaspar requested a review from eschutho August 31, 2022 12:39
@dpgaspar dpgaspar merged commit 3f2e894 into apache:master Aug 31, 2022
@dpgaspar dpgaspar deleted the danielgaspar/sc-53952/superset-fix-when-a-virtual-dataset-is-changed branch August 31, 2022 17:11
zephyring pushed a commit to preset-io/superset that referenced this pull request Sep 15, 2022
* fix: dataset name change and permission change

(cherry picked from commit 3f2e894)
@sadpandajoe
Copy link
Contributor

🏷️ preset:2022.35

eschutho pushed a commit that referenced this pull request Sep 20, 2022
* fix: dataset name change and permission change
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset:2022.35 size/XXL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants