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

feat(dashboard_rbac): dashboard lists #12680

Merged
merged 50 commits into from
Jan 31, 2021

Conversation

amitmiran137
Copy link
Member

@amitmiran137 amitmiran137 commented Jan 22, 2021

SUMMARY

Role based dashboard level access with focus on dashboard list APIs

credits also goes to @Ofeknielsen who took part in this months ago

resolves #10408

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2021-01-23.at.14.12.29.mov

Design slide;

https://user-images.githubusercontent.com/4025227/105494222-6302e400-5cb2-11eb-8f0d-6a609d73cc6c.png

TEST PLAN

ff:
DASHBOARD_RBAC: True
ENABLE_REACT_CRUD_VIEWS: False

happy path:

  1. create a new user X with Gamma role
  2. edit a dashboard and add to roles the Gamma role
  3. login as X and see the assigned dashboard

backward compatibility:
check backward compatibility by DASHBOARD_RBAC: False
access should be managed by the data level

code test coverage plan

dashboards list page for the following scenarios both for dataset and RBAC levels
To make sure we keep backward compatibility and new feature alignment on capabilities

  1. an anonymous user
  2. a non-admin (test user: alpha/general)
  3. admin
  4. owner
  5. Published/ non published

Test need to be written in a decoupled approch from existing users/roles/tables/dashboards so other tests suites won't break

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Jan 22, 2021

Codecov Report

Merging #12680 (812bb87) into master (017f11f) will increase coverage by 3.85%.
The diff coverage is 60.86%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12680      +/-   ##
==========================================
+ Coverage   63.13%   66.98%   +3.85%     
==========================================
  Files        1022     1022              
  Lines       50032    50186     +154     
  Branches     4915     5204     +289     
==========================================
+ Hits        31587    33618    +2031     
+ Misses      18245    16433    -1812     
+ Partials      200      135      -65     
Flag Coverage Δ
cypress 50.82% <ø> (?)
javascript 61.93% <ø> (+0.25%) ⬆️
python 63.98% <60.86%> (-0.11%) ⬇️

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

Impacted Files Coverage Δ
superset/config.py 90.61% <ø> (ø)
...11ccdd12658_add_roles_relationship_to_dashboard.py 0.00% <0.00%> (ø)
superset/views/dashboard/mixin.py 95.00% <ø> (ø)
superset/dashboards/filters.py 97.61% <100.00%> (+0.64%) ⬆️
superset/models/dashboard.py 75.74% <100.00%> (+0.24%) ⬆️
superset/utils/celery.py 89.65% <0.00%> (-10.35%) ⬇️
superset/utils/cache.py 76.34% <0.00%> (-8.77%) ⬇️
superset/db_engine_specs/presto.py 82.25% <0.00%> (-6.28%) ⬇️
...hboard/components/nativeFilters/CascadePopover.tsx 18.18% <0.00%> (-4.46%) ⬇️
...terControl/AdhocFilterEditPopoverSqlTabContent.jsx 63.33% <0.00%> (-2.19%) ⬇️
... and 217 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 017f11f...812bb87. Read the comment docs.

@amitmiran137 amitmiran137 changed the title Feat/dashboard access roles Feat: dashboard access roles Jan 22, 2021
Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

Could you add a test plan and maybe some test cases?

I think we should at least test visiting the dashboards list page as each of the following:

  1. an anonymous user
  2. a non-admin (test user: alpha/general)
  3. admin

superset/dashboards/filters.py Outdated Show resolved Hide resolved
superset/dashboards/filters.py Outdated Show resolved Hide resolved
@villebro villebro changed the title Feat: dashboard access roles feat: dashboard access roles Jan 22, 2021
@amitmiran137

This comment has been minimized.

@dpgaspar
Copy link
Member

dpgaspar commented Jan 22, 2021

I like this approach, IMO we should move to include database, datasets and charts to this pattern also. I personally would like to deprecate string based permissions constructed based on the dataset.name and dataset.id for example.

Recalling a diagram
Blank diagram (6)

@junlincc junlincc added the dashboard:security:access Related to the security access of the Dashboard label Jan 22, 2021
@ktmud
Copy link
Member

ktmud commented Jan 25, 2021

can you vote please so we can move forward with this in a non-POC approach?

Just saw it has passed. :D Didn't notice you've updated the SIP summary. Thanks for iterating on your proposal and creating this POC!

@dpgaspar's diagram makes perfect sense to me. Looks like things can be even simpler than I original thought. Maybe include the diagram in the SIP as a reference, too?

amitmiran137 added 3 commits January 26, 2021 21:58
* master: (52 commits)
  docs: Updates to Superset Site for 1.0 (apache#12626)
  test(native-filters): scoping tree in native filters modal (apache#12655)
  Fix tests errors and warnings - iteration 3 (apache#12212) (apache#12219)
  Fix tests errors and warnings - iteration 5 (apache#12212) (apache#12224)
  Fix tests errors and warnings - iteration 6 (apache#12212) (apache#12227)
  feat(native-filters): apply scoping of native filters to dashboard (apache#12716)
  Fix tests errors and warnings - iteration 4 (apache#12212) (apache#12223)
  Fix tests errors and warnings - iteration 7 (apache#12212) (apache#12245)
  fix: missing select menu background (apache#12759)
  fix(explore): incorrect missing datasource condition (apache#12758)
  feat: default timepicker to last week when dataset is changed (apache#12609)
  feat(explore): allow opening charts with missing dataset (apache#12705)
  chore: upgrade Cypress to 6.2.1 (apache#12605)
  refactor(explore): Enhance Dataset and Control panel Collapse components (apache#12218)
  feat: Adding option to set_database_uri CLI command (apache#12740)
  docs: Fixed typo on line 348 (apache#12739)
  Fix tests errors and warnings - iteration 2 (apache#12212) (apache#12214)
  docs: Remove gatsby-plugin-offline (apache#12693)
  test: oracle engine spec (apache#12615)
  test: hive db engine spec (apache#12520)
  ...
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Small proposal to improve how the feature flag is handled

superset/dashboards/filters.py Outdated Show resolved Hide resolved
superset/dashboards/filters.py Outdated Show resolved Hide resolved
superset/dashboards/filters.py Outdated Show resolved Hide resolved
superset/dashboards/filters.py Outdated Show resolved Hide resolved
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Code LGTM, tested the following:

  • FF enabled: no roles for dashboard works like before
  • FF enabled: role specified - only shows up for the roles listed on the dashboard
  • FF disabled: roles don't affect dashboard visibility

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

Looking great! Thanks for the iterations.

@junlincc junlincc added the hold:testing! On hold for testing label Jan 31, 2021
@junlincc
Copy link
Member

Screen Shot 2021-01-30 at 10 36 57 PM

Settings menu is missing from the page, is it by design?

@junlincc
Copy link
Member

Screen.Recording.2021-01-30.at.10.41.59.PM.mov

tested~ for some reason, getting "unexpected errors" on all charts in the dashboard from gamma account. is it something I did wrong? @amitmiran137

@amitmiran137
Copy link
Member Author

Screen.Recording.2021-01-30.at.10.41.59.PM.mov
tested~ for some reason, getting "unexpected errors" on all charts in the dashboard from gamma account. is it something I did wrong? @amitmiran137

thanks for checking this.
this PR focuses on the backend filtering the list of dashboards by the access given to the user.
if a user was given access to the Dashboard, that alone is not enough, and access to the relevant dataset still needs to be provided.
having said that, we plan in a follow-up PR that user will be given temporary read access to all of the datasets within a dashboard as was mentioned in the development milestones in #10408
allow token-based access to /explore_json and API/v1/chart/data to allow reading datasets only by have dashboard access for read-only purpose

@amitmiran137 amitmiran137 changed the title feat: dashboard access roles feat(dashboard-rbac): dashboard lists Jan 31, 2021
@junlincc
Copy link
Member

having said that, we plan in a follow-up PR that user will be given temporary read access to all of the datasets within a dashboard as was mentioned in the development milestones in #10408

Got it, thanks for adding test plan, and clarifying your plan going forward. we should expect a follow up PR to address both issues mentioned above.

@junlincc junlincc self-requested a review January 31, 2021 07:05
Copy link
Member

@junlincc junlincc left a comment

Choose a reason for hiding this comment

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

Approving as product signoff. thank you so much for your contribution. 🙏

@junlincc junlincc removed the hold:testing! On hold for testing label Jan 31, 2021
@villebro villebro merged commit 9a7fba8 into apache:master Jan 31, 2021
@amitmiran137 amitmiran137 deleted the feat/dashboard_access_roles branch January 31, 2021 11:54
@srinify srinify changed the title feat(dashboard-rbac): dashboard lists feat(dashboard_rbac): dashboard lists Mar 23, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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 dashboard:security:access Related to the security access of the Dashboard size/XXL 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SIP-51] Dashboard Level Access
7 participants