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

chore: Add granular permissions for actions in Dashboard #27029

Merged
merged 19 commits into from
Feb 9, 2024

Conversation

geido
Copy link
Member

@geido geido commented Feb 6, 2024

SUMMARY

This PR introduced a new permission to enable view and drilling actions on the Dashboard independently of the can_explore permission #26798. However, from recent feedback it is clear that the need is to have more granularity for these permissions.

This PR introduces the following permissions:

  • can_view_chart_as_table to enable the "View as table" option in the chart actions in a Dashboard
  • can_view_query to enable the "View query" option in the chart actions in a Dashboard

This PR also implements the following changes:

  • It removes the permission can_view_and_drill introduced in chore: Add permission to view and drill on Dashboard context #26798.
  • It ties Drill to detail to both can_explore and can_samples as can_samples is a required backend permission for Drill to detail to work
  • It ties Drill by to both can_explore and can_write_ExploreFormDataRestAPI as the latter is a required backend permissions for the submission of form data when interacting with Drill by

Fixes #26762
Fixes #25630

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N.A.

TESTING INSTRUCTIONS

  • CI should pass
  • A role with can_view_chart_as_table should see the View as table option without can_explore permission
  • A role with can_view_query should see the View query option without can_explore permission
  • A role without can_samples should not be able to see Drill to detail
  • A role without can_write_ExploreFormDataRestAPI should not see Drill by

ADDITIONAL INFORMATION

@geido geido requested a review from kgabryje February 6, 2024 15:48
@@ -726,7 +726,8 @@ def create_custom_permissions(self) -> None:
self.add_permission_view_menu("can_csv", "Superset")
self.add_permission_view_menu("can_share_dashboard", "Superset")
self.add_permission_view_menu("can_share_chart", "Superset")
self.add_permission_view_menu("can_view_and_drill", "Dashboard")
Copy link
Member

Choose a reason for hiding this comment

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

I know that can_view_and_drill permission wasn't around for long so probably few people have used it, but shouldn't we create a migration for it?

Copy link
Member

Choose a reason for hiding this comment

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

It'd be nice to have a reusable function for perm migration that we could use in database migrations. Now that we have migration_utils.py in theory it could contain a function migrate_permission(before_perm, after_perm). Though in theory it should only be use for equivalent (rename) or more atomic/selective permissions.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

hi I have all roles. And can not see drill down menu in superset graphs. Why?

Copy link
Member

Choose a reason for hiding this comment

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

hi I have all roles. And can not see drill down menu in superset graphs. Why?

Just to ask basic support questions, are you not seeing them in ANY chart, or just not EVERY chart? They're still not supported everywhere. They also appear on right-cick, which might not be the most discoverable thing in the world :)

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (13915bb) 67.19% compared to head (3c4cdb2) 69.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27029      +/-   ##
==========================================
+ Coverage   67.19%   69.54%   +2.34%     
==========================================
  Files        1899     1899              
  Lines       74380    74385       +5     
  Branches     8275     8276       +1     
==========================================
+ Hits        49981    51728    +1747     
+ Misses      22344    20602    -1742     
  Partials     2055     2055              
Flag Coverage Δ
hive 53.81% <100.00%> (?)
javascript 56.91% <100.00%> (+<0.01%) ⬆️
mysql 78.01% <100.00%> (+<0.01%) ⬆️
postgres 78.14% <100.00%> (+0.03%) ⬆️
presto 53.76% <100.00%> (?)
python 83.10% <100.00%> (+4.85%) ⬆️
sqlite 77.66% <100.00%> (+0.03%) ⬆️
unit 56.49% <0.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@geido geido requested a review from a team as a code owner February 7, 2024 15:32
@github-actions github-actions bot added the risk:db-migration PRs that require a DB migration label Feb 7, 2024
…o/ch77449/dashboard-granular-permissions
@sfirke
Copy link
Member

sfirke commented Feb 7, 2024

Would this PR address or affect open issue #25630?

It looks relevant to open issue #26762, at a glance it would not solve it (Gamma would still need can_samples) but if someone working on this PR felt in the right headspace to tackle this issue it would save on task switching costs.

…o/ch77449/dashboard-granular-permissions
@geido geido requested a review from dpgaspar February 8, 2024 09:29
@geido
Copy link
Member Author

geido commented Feb 8, 2024

Would this PR address or affect open issue #25630?

It looks relevant to open issue #26762, at a glance it would not solve it (Gamma would still need can_samples) but if someone working on this PR felt in the right headspace to tackle this issue it would save on task switching costs.

@sfirke in terms of fixing the mentioned issues, I think this PR should be the solution. Drill to detail must be tied to can_samples in order to function and can_explore to respect the current permission dependency on the UI. Drill by requires can_write on ExploreFormDataRestApi or there will be an error message showing up when posting form data, together with can_explore based on current permission dependency on the UI. I haven't checked whether these permissions can work without can_explore but my objective here is to avoid a breaking change.

The View as table and View query options now can be enabled granularly and the Edit chart buttons in the respective Modals will be disabled if can_explore is OFF.

As for what concerns assigning/changing permissions of the existing roles, this is beyond the scope of this PR and I think it would be best to discuss this opportunity in the appropriate channels. Thanks!

@kgabryje
Copy link
Member

kgabryje commented Feb 8, 2024

@geido I think drill by needs the can_explore permission only for the "Edit chart" button. If we made that button conditionally disabled if user doesn't have access to Explore and sent the post request in line 90 in DrillByModal.tsx, then the feature should work just fine without can_explore.
That would solve the issues that @sfirke linked in his comment

@geido
Copy link
Member Author

geido commented Feb 8, 2024

@geido I think drill by needs the can_explore permission only for the "Edit chart" button. If we made that button conditionally disabled if user doesn't have access to Explore and sent the post request in line 90 in DrillByModal.tsx, then the feature should work just fine without can_explore. That would solve the issues that @sfirke linked in his comment

That's right. Drill by does not need can_explore. However, removing can_explore would cause Drill by to show up and it might not be the expected behaviour for most people at this point. I think having granular permissions for both Drill by and Drill to detail could be a better approach to remove the dependency on can_explore. @yousoph what do you think?

I would aim to merge this PR as it is and continue in a follow-up.

@geido geido merged commit 595c6ce into master Feb 9, 2024
43 checks passed
@rusackas rusackas deleted the diego/ch77449/dashboard-granular-permissions branch February 9, 2024 16:15
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
@dimoha
Copy link

dimoha commented Apr 4, 2024

Hi

I think that i found a small bug
#27896

can you check it?

@icrc-fdeniger
Copy link

hello @geido

However, removing can_explore would cause Drill by to show up and it might not be the expected behaviour for most people at this point

Is there a plan to allow end-users to be able to Drill with having can_explore ?

Thanks

@rusackas
Copy link
Member

rusackas commented Apr 4, 2024

For the sake of the thread, @icrc-fdeniger opened an issue regarding that permission question: #27900

@puru-khedre
Copy link

Hello @geido @dpgaspar
In which release this PR is merged, I want that permissions set

Or How can I know the release which has this permissions

@michael-s-molina
Copy link
Member

michael-s-molina commented Apr 17, 2024

Hello @geido @dpgaspar In which release this PR is merged, I want that permissions set

Or How can I know the release which has this permissions

Hi @puru-khedre. You can always check the CHANGELOG to see if a particular PR was included in a release. This one was included in 4.0.0 as you can see here.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.0.0 labels Apr 17, 2024
@puru-khedre
Copy link

Hi @puru-khedre. You can always check the CHANGELOG to see if a particular PR was included in a release. This one was included in 4.0.0 as you can see here.

Thanks @michael-s-molina

@agunoglu
Copy link

agunoglu commented May 3, 2024 via email

@geido
Copy link
Member Author

geido commented May 10, 2024

Hello @agunoglu can_view_and_drill was removed. Are you running on latest master?

@saurabh-innovator
Copy link

Hi @geido , I want to understand that why can_view_and_drill permission was removed. Issue that I am facing is, I wish to have a read-user who can just view chart table and just drill. I don't want to expose the query/edit/chart. That was the very good use case which you implemented, so why you removed it, also How can I again implement my case?

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 risk:db-migration PRs that require a DB migration size/L 🚢 4.0.0
Projects
None yet