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: Dashboard aware RBAC "Save as" menu item #24806

Merged

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Jul 26, 2023

SUMMARY

This PR (alongside #24789) fixes #24782.

Specifically (per #24782 (comment)) this PR ensures that the Save as menu item is not present when the DASHBOARD_RBAC feature is enabled and the user is neither an admin nor an owner. Note it's unclear whether a non-owner (irrespective of the feature flag setting) should ever be able to Save as a dashboard, though this PR simply preserves said behavior.

Regarding the backend logic he DashboardRestApi.copy_dash method invokes the @with_dashboard decorator which in turn calls DashboardDAO.get_by_id_or_slug which has the necessary security checks to ensure ensure said user has access. The conundrum is, if you ask where the user has access to the dashboard the answer is "yes", even though we're stating they can't copy it. The solution to this seems to be to add logic within the dashboard DAO.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE

Screenshot 2023-07-25 at 5 22 36 PM

AFTER

Screenshot 2023-07-25 at 3 50 50 PM

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

cc: @mdeshmu @sfirke

@john-bodley john-bodley force-pushed the john-bodley--fix-24782-save-as branch from 9a7403c to c04f3f6 Compare July 26, 2023 00:26
@john-bodley john-bodley changed the title fix: Dashboard aware RBAC menu items fix: Dashboard aware RBAC "Save as" menu item Jul 26, 2023
@john-bodley john-bodley force-pushed the john-bodley--fix-24782-save-as branch 3 times, most recently from 86e1352 to 310efc7 Compare July 26, 2023 03:33
@john-bodley john-bodley marked this pull request as ready for review July 26, 2023 04:02
@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Merging #24806 (089896f) into master (5522fac) will increase coverage by 0.00%.
Report is 2 commits behind head on master.
The diff coverage is 36.00%.

❗ Current head 089896f differs from pull request most recent head fe44656. Consider uploading reports for the commit fe44656 to get more accurate results

@@           Coverage Diff           @@
##           master   #24806   +/-   ##
=======================================
  Coverage   69.00%   69.00%           
=======================================
  Files        1906     1906           
  Lines       74138    74147    +9     
  Branches     8208     8209    +1     
=======================================
+ Hits        51158    51166    +8     
- Misses      20857    20858    +1     
  Partials     2123     2123           
Flag Coverage Δ
hive 54.17% <4.34%> (-0.01%) ⬇️
javascript 55.84% <100.00%> (+<0.01%) ⬆️
mysql 79.21% <30.43%> (+<0.01%) ⬆️
postgres 79.31% <30.43%> (+<0.01%) ⬆️
presto 54.07% <4.34%> (-0.01%) ⬇️
python 83.37% <30.43%> (+<0.01%) ⬆️
sqlite 77.89% <30.43%> (+<0.01%) ⬆️
unit 55.04% <4.34%> (-0.01%) ⬇️

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

Files Changed Coverage Δ
superset-frontend/src/dashboard/actions/hydrate.js 2.04% <ø> (ø)
...et-frontend/src/dashboard/components/SaveModal.tsx 39.28% <ø> (ø)
superset/cli/native_filters.py 0.00% <0.00%> (ø)
...uperset/utils/dashboard_filter_scopes_converter.py 15.38% <0.00%> (-0.41%) ⬇️
...set-frontend/src/dashboard/util/permissionUtils.ts 88.23% <100.00%> (+1.56%) ⬆️
superset/daos/dashboard.py 96.77% <100.00%> (+0.04%) ⬆️
superset/dashboards/api.py 92.60% <100.00%> (+0.05%) ⬆️

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

@mdeshmu
Copy link
Contributor

mdeshmu commented Aug 3, 2023

@john-bodley can you please look into failing tests.

@john-bodley john-bodley force-pushed the john-bodley--fix-24782-save-as branch 7 times, most recently from 67ad0c3 to 3690a8c Compare August 4, 2023 21:31
@mdeshmu
Copy link
Contributor

mdeshmu commented Aug 5, 2023

@betodealmeida @villebro @michael-s-molina Please review this.

@michael-s-molina
Copy link
Member

I think you mistakenly committed _update-notifier-last-checked. Could you delete it?

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but please remove _update-notifier-last-checked before merging it.

@john-bodley john-bodley force-pushed the john-bodley--fix-24782-save-as branch 2 times, most recently from 0c98ff9 to c6eff95 Compare August 9, 2023 16:43
@john-bodley john-bodley force-pushed the john-bodley--fix-24782-save-as branch from c6eff95 to fe44656 Compare August 9, 2023 18:45
@john-bodley john-bodley merged commit f6c3f0c into apache:master Aug 9, 2023
29 checks passed
@john-bodley john-bodley deleted the john-bodley--fix-24782-save-as branch August 9, 2023 20:39
@mdeshmu mdeshmu mentioned this pull request Aug 10, 2023
9 tasks
@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Aug 10, 2023
michael-s-molina pushed a commit that referenced this pull request Aug 10, 2023
@mistercrunch mistercrunch added 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 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 size/L v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
4 participants