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): provide data access based on dashboard access #13992

Merged
merged 18 commits into from Apr 13, 2021

Conversation

amitmiran137
Copy link
Member

SUMMARY

This is the second milestone in dashboard_rbac support where having a dashboard role entitles the user data access to all of the datasets within a dashboard

following @suddjian recommendation on an existing PR, I decided to take a simpler solution

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

dashboard_data_access.mov

TEST PLAN

  1. enable DASHBOARD_RBAC ff
  2. create a separated user with Gamma role
  3. on dashboard properties give Gamma role access to the dashboard
  4. sign in as the gamma user
  5. check that he can access the dashboard and all charts all loaded inside

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@etr2460
Copy link
Member

etr2460 commented Apr 7, 2021

Is this the default behavior we want to support? I wonder if there's value in creating alternate SecurityManagerPlugins for different use cases, and then if you wanted dashboard_rbac for your deployment, you'd use the specific SecurityManager for that use case.

Mainly asking as I haven't been following this work too closely, and this looks like a fairly specific change (for example it doesn't apply to Druid datasources and assumes that a BaseDatasource is always a SqlaTable)

@amitmiran137
Copy link
Member Author

Is this the default behavior we want to support? I wonder if there's value in creating alternate SecurityManagerPlugins for different use cases, and then if you wanted dashboard_rbac for your deployment, you'd use the specific SecurityManager for that use case.

Mainly asking as I haven't been following this work too closely, and this looks like a fairly specific change (for example it doesn't apply to Druid datasources and assumes that a BaseDatasource is always a SqlaTable)

the entire feature is under the DASHBOARD_RBAC ff
and about the druid datasources, I'll change it to use the BaseDatasource

@etr2460
Copy link
Member

etr2460 commented Apr 7, 2021

it's under the feature flag, but this check is added to the security manager without the feature flag right? should we be checking the flag here too?

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 7, 2021
@amitmiran137
Copy link
Member Author

it's under the feature flag, but this check is added to the security manager without the feature flag right? should we be checking the flag here too?

thank you for the input, I added the the FF restriction and the more generic support for table

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Nice, much cleaner implementation! Happy to approve once the new method has some tests.

superset/security/manager.py Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/S and removed size/M labels Apr 7, 2021
@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #13992 (33d64d5) into master (b394733) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

❗ Current head 33d64d5 differs from pull request most recent head 573ed3e. Consider uploading reports for the commit 573ed3e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13992      +/-   ##
==========================================
- Coverage   79.76%   79.64%   -0.12%     
==========================================
  Files         942      942              
  Lines       47675    47689      +14     
  Branches     5984     5984              
==========================================
- Hits        38029    37984      -45     
- Misses       9525     9584      +59     
  Partials      121      121              
Flag Coverage Δ
cypress 56.31% <ø> (-0.01%) ⬇️
hive ?
javascript 69.67% <ø> (ø)
mysql 80.73% <100.00%> (+0.01%) ⬆️
postgres 80.76% <100.00%> (?)
presto 80.48% <100.00%> (+0.01%) ⬆️
python 81.06% <100.00%> (-0.22%) ⬇️
sqlite 80.36% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...src/dashboard/components/PropertiesModal/index.jsx 85.61% <ø> (ø)
superset/views/dashboard/mixin.py 95.00% <ø> (ø)
superset/security/manager.py 91.43% <100.00%> (+0.34%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 74.42% <0.00%> (-16.42%) ⬇️
...dashboard/components/SliceHeaderControls/index.jsx 77.89% <0.00%> (-1.06%) ⬇️
superset/connectors/sqla/models.py 89.69% <0.00%> (-0.25%) ⬇️
superset/utils/core.py 88.70% <0.00%> (-0.13%) ⬇️
superset/views/base_api.py 98.28% <0.00%> (+0.42%) ⬆️
superset/db_engine_specs/postgres.py 96.80% <0.00%> (+1.06%) ⬆️
... and 1 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 b394733...573ed3e. Read the comment docs.

@amitmiran137 amitmiran137 reopened this Apr 8, 2021
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.

First pass comments

superset/security/manager.py Show resolved Hide resolved
superset/security/manager.py Outdated Show resolved Hide resolved
superset/security/manager.py Outdated Show resolved Hide resolved
@junlincc junlincc added dashboard:security:access Related to the security access of the Dashboard release:note labels Apr 8, 2021
amitmiran137 and others added 2 commits April 9, 2021 08:49
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
tests/utils_tests.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.

A few minor comments. Should we update this string to state that granting a role access to a dashboard will bypass datasource level checks?

"These roles are always applied in addition to restrictions on dataset "
"level access. "
Or should we rather add a new config flag in which we can specify that dashboard RBAC either overrides or is supplemental to dataset access control?

superset/security/manager.py Outdated Show resolved Hide resolved
superset/security/manager.py Outdated Show resolved Hide resolved
@amitmiran137
Copy link
Member Author

amitmiran137 commented Apr 9, 2021

IMO we should just change the string the explains instead of an additional feature flag.

That way both use cases could live on different dashboards
One dashboard can use roles while the other can use dataset permissions

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Thanks for all the adjustments, looks good!

* master: (53 commits)
  test: Adds tests to the UndoRedoKeyListeners component (#13919)
  chore: Adds dataMask reducer to reducerIndex (#13951)
  test: Tests audit for the Dashboard FilterBar (#13916)
  fix: unable to apply logging format (#14074)
  refactor: Bootstrap to AntD - Slider (#13989)
  chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306)
  fix(listview): update listview feature flag (#13906)
  Add docs for configuring Docker Compose setup (#13961)
  feat: invalid password error message (Postgres) (#14038)
  fix: flacky test in test_update_dataset_item_w_override_columns (#14082)
  feat: Implement Celery SoftTimeLimit handling (#13740)
  feat: only send alert error emails to owners of the alert (#13862)
  feat: add descriptions to report emails (#13827)
  Make chart exclude itself from cross filtering (#14046)
  fix: fix bug when remove chart not  removing it's related cross filter data (#14081)
  feat(native-filters): Add default first value to select filter (#13726)
  feat: Make async query JWT cookie domain configurable (#14007)
  fix: add exception to catch session not having JWT (#14036)
  Use consistent chart value (#14031)
  fix: Use superset generic db to catch external_metadata queries (#13974)
  ...
@amitmiran137 amitmiran137 merged commit 8c5b6b1 into master Apr 13, 2021
@tejpochiraju
Copy link

Just here to say thanks! I was just starting to implement a rather complex role + user API integration to automate access from our IoT platform. This solves half the problem 👍🏾

QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
…pache#13992)

* feat: provide data access based onb dashboard access

* chore: adjust code after CR comments

* fix: add brackets

* fix: type

* chore: add tests

* fix: pre-commit

* fix: pre-commit and lint

* fix: fix test

* fix: pre-commit

* fix: fix local pylint warnings

* revert: birth_names pylint  change bc it  affects tests

* Update superset/security/manager.py

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update superset/security/manager.py

* Update tests/utils_tests.py

* fix: after CR

* fix: after CR from ville

* chore: update roles description

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
@MM-Lehmann
Copy link

The fallback (to dataset perms) doesn't seem to work on v1.4.1
When the FF is active, no access is granted to any dashboard unless roles are set in dashboards. It doesn't look like the intended behaviour...

@nikhil-kuyya-talentas
Copy link

nikhil-kuyya-talentas commented Mar 11, 2022

Thank you for pull request on role based controls. I am trying to extend to our(my company) requirement to chart level.
Can you help me if possible, how these can_access_based_on_dashboard method query is working little bit.
[Update]: got the understanding,
[MySolution]: I have created the custom can_access_based_on_chart and passed extra slice_id parameter.

@nikhil-kuyya-talentas
Copy link

should we check the can_access_based_on_dashboard if there is not slice_id in query_context and viz.
given that i don't have access to data menu items.

  • These case when i come to explore view by typing the url. <host_name>/superset/explore/table/1/
  • Select the explore options for the data and query. now in these it works and fetch the data for me.

@rusackas rusackas deleted the feat/dashboard_dataset_access branch January 30, 2023 19:21
@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 release:note size/M 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants