You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "john-bodley (via GitHub)" <gi...@apache.org> on 2023/07/25 03:09:26 UTC

[GitHub] [superset] john-bodley opened a new pull request, #24789: fix: Dashboard aware RBAC dataset permission

john-bodley opened a new pull request, #24789:
URL: https://github.com/apache/superset/pull/24789

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652262982

   Thanks @Vitor-Avila for confirming. I thought that might be the case as the dashboard information is likely lacking from the form-data when the native dashboard filter datasource check is happening. https://github.com/apache/superset/pull/24804 is simply a refactor and thus wouldn't change anything.
   
   The challenge with the RBAC feature is opening up access only in the context of a dashboard. Furthermore I sense there's actually a flaw with the model, i.e., a Gamma user (who has been granted access to a dashboard) could likely have broader access than an owner as it pertains to how access is determined for the datasets within the dashboard which are driving the native filters and charts.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1281656072


##########
superset/security/manager.py:
##########
@@ -1827,25 +1826,26 @@ def raise_for_access(
                 )
 
         if datasource or query_context or viz:
+            form_data = None
+
             if query_context:
                 datasource = query_context.datasource
+                form_data = query_context.form_data
             elif viz:
                 datasource = viz.datasource
+                form_data = viz.form_data
 
             assert datasource
 
-            should_check_dashboard_access = (
-                feature_flag_manager.is_feature_enabled("DASHBOARD_RBAC")
-                or self.is_guest_user()
-            )
-
             if not (
                 self.can_access_schema(datasource)
                 or self.can_access("datasource_access", datasource.perm or "")
                 or self.is_owner(datasource)
                 or (
-                    should_check_dashboard_access
-                    and self.can_access_based_on_dashboard(datasource)
+                    form_data
+                    and (dashboard_id := form_data.get("dashboardId"))
+                    and (dashboard := DashboardDAO.find_by_id(dashboard_id))
+                    and self.can_access_dashboard(dashboard)

Review Comment:
   Do we need to check that the purported chart whose data is being loaded actually exists on the dashboard?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Vitor-Avila commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652528700

   sure, that makes sense! It could also be a good opportunity to revisit if both flows (`DASHBOARD_RBAC` and guest user) should be handled in a more distinct way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273010307


##########
tests/integration_tests/security/guest_token_security_tests.py:
##########
@@ -159,41 +159,6 @@ def test_has_guest_access__unauthorized_guest_user__different_resource_type(self
         has_guest_access = security_manager.has_guest_access(self.dash)
         self.assertFalse(has_guest_access)
 
-    def test_chart_raise_for_access_as_guest(self):

Review Comment:
   Conditional on my logic being correct, these tests are now superfluous as the irrespective of whether a guest is authorized or not, they don't have access to the chart, dataset, etc. unless it's in the context of RBAC.  The logic previously outlined here condenses to the same logic which is defined in the `security_tests.py`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1648982840

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#24789](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (bf27c96) into [master](https://app.codecov.io/gh/apache/superset/commit/e06004292aafe09e4da1b5c4bdab824d09f2206f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (e060042) will **decrease** coverage by `10.68%`.
   > The diff coverage is `63.82%`.
   
   > :exclamation: Current head bf27c96 differs from pull request most recent head 264821c. Consider uploading reports for the commit 264821c to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #24789       +/-   ##
   ===========================================
   - Coverage   68.94%   58.27%   -10.68%     
   ===========================================
     Files        1902     1902               
     Lines       73939    73988       +49     
     Branches     8176     8195       +19     
   ===========================================
   - Hits        50977    43114     -7863     
   - Misses      20849    28755     +7906     
   - Partials     2113     2119        +6     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `54.05% <47.94%> (+0.01%)` | :arrow_up: |
   | python | `60.98% <52.05%> (-22.36%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `54.96% <46.57%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files Changed](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [superset-frontend/src/components/Select/utils.tsx](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvU2VsZWN0L3V0aWxzLnRzeA==) | `82.25% <ø> (-1.62%)` | :arrow_down: |
   | [superset/charts/commands/delete.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2hhcnRzL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `43.58% <ø> (-48.72%)` | :arrow_down: |
   | [superset/charts/commands/warm\_up\_cache.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2hhcnRzL2NvbW1hbmRzL3dhcm1fdXBfY2FjaGUucHk=) | `27.77% <0.00%> (-70.38%)` | :arrow_down: |
   | [superset/charts/filters.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2hhcnRzL2ZpbHRlcnMucHk=) | `66.66% <ø> (-21.74%)` | :arrow_down: |
   | [superset/cli/importexport.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2xpL2ltcG9ydGV4cG9ydC5weQ==) | `20.00% <ø> (-60.00%)` | :arrow_down: |
   | [superset/cli/main.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2xpL21haW4ucHk=) | `0.00% <0.00%> (ø)` | |
   | [superset/cli/update.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2xpL3VwZGF0ZS5weQ==) | `0.00% <ø> (ø)` | |
   | [superset/commands/exceptions.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvZXhjZXB0aW9ucy5weQ==) | `81.53% <ø> (-12.31%)` | :arrow_down: |
   | [superset/commands/importers/v1/examples.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvaW1wb3J0ZXJzL3YxL2V4YW1wbGVzLnB5) | `0.00% <0.00%> (ø)` | |
   | [superset/common/query\_context\_factory.py](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X2NvbnRleHRfZmFjdG9yeS5weQ==) | `73.91% <ø> (-2.90%)` | :arrow_down: |
   | ... and [85 more](https://app.codecov.io/gh/apache/superset/pull/24789?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   ... and [226 files with indirect coverage changes](https://app.codecov.io/gh/apache/superset/pull/24789/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley merged pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley merged PR #24789:
URL: https://github.com/apache/superset/pull/24789


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1679799909

   @john-bodley I discovered that this PR introduces a security issue that can allow any user to get data from any datasource.  I've opened https://github.com/apache/superset/pull/24996 to revert this, see the PR description there for more details


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273005318


##########
tests/integration_tests/dashboards/security/security_rbac_tests.py:
##########
@@ -191,7 +190,7 @@ def test_get_dashboard_view__user_access_with_dashboard_permission(self):
 
         request_payload = get_query_context("birth_names")
         rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
-        self.assertEqual(rv.status_code, 200)
+        self.assertEqual(rv.status_code, 403)

Review Comment:
   This test (which was failing after the change) indicates that either i) RBAC were supposed to expend beyond the scope/context of the dashboard, or ii) was a mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] michael-s-molina commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1663926945

   > @michael-s-molina can this be included in 3.0 ?
   
   @mdeshmu All `fix` PRs that affect 3.0 will be included in the release. I'm cherry-picking them daily. If a `fix` PR is not merged by the time we release 3.0.0, it will be included right after it in 3.0.1. We're planning to submit patch releases every 2 weeks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Vitor-Avila commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652327861

   @john-bodley sorry I mis-read https://github.com/apache/superset/pull/24804 and thought you were re-adding the logic for `can_access_based_on_dashboard` somewhere else, but that's not true - I was confused with the `raise_for_dashboard_access` function. My apologies for the confusion.
   
   In my previous test, I had only checked the issue I'm trying to fix for embedded users, but I just tried with the `DASHBOARD_RBAC` access as well and confirmed it also happens for this flow:
   <img width="794" alt="image" src="https://github.com/apache/superset/assets/96086495/0424cb6e-3cbe-4693-8f78-c398934e6f48">
   
   Not sure if we can keep the `can_access_based_on_dashboard` function or if that's not compatible with the work you've been doing in these PRs. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1276507822


##########
superset/security/manager.py:
##########
@@ -1827,25 +1826,26 @@ def raise_for_access(
                 )
 
         if datasource or query_context or viz:
+            form_data = None
+
             if query_context:
                 datasource = query_context.datasource
+                form_data = query_context.form_data
             elif viz:
                 datasource = viz.datasource
+                form_data = viz.form_data
 
             assert datasource
 
-            should_check_dashboard_access = (
-                feature_flag_manager.is_feature_enabled("DASHBOARD_RBAC")
-                or self.is_guest_user()
-            )
-
             if not (
                 self.can_access_schema(datasource)
                 or self.can_access("datasource_access", datasource.perm or "")
                 or self.is_owner(datasource)
                 or (
-                    should_check_dashboard_access
-                    and self.can_access_based_on_dashboard(datasource)
+                    form_data
+                    and (dashboard_id := form_data.get("dashboardId"))
+                    and (dashboard := DashboardDAO.find_by_id(dashboard_id))
+                    and self.can_access_dashboard(dashboard)

Review Comment:
   I'm not too familiar with this feature either, but just noticed that the previous version checks for datasource access and the new one checks for dashboard access only. Is that what we want?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Vitor-Avila commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652196487

   hey @john-bodley, thanks for the quick response! 
   
   My PR was actually not created with the `DASHBOARD_RBAC` FF in mind, but actually focusing on embedded access for dashboards. I'm not sure if the permission flow/logic is the same between guest user/dashboard RBAC access, but I know at least for embedded access you would only specify the dashboard `uuid` when generating the `guest_token`, and I believe the expectation is that the user should be able to view all charts and filters used in the specified dashboard. For embedded dashboards, it's also not possible to access Charts directly (at least not through the iframe) -- but likely through the API.
   
   I'll test if my issue is also addressed with your branch and report back -- thank you! 🙏 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1653922916

   @john-bodley are you ok with us merging https://github.com/apache/superset/pull/24808 while we wait for more feedback on RBAC for this PR? @Vitor-Avila's PR isn't for the DASHBOARD_RBAC flag specifically. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1653970038

   @eschutho I added some comments to https://github.com/apache/superset/pull/24808. I _think_ the underlying logic outlined in said PR is likely correct and thus it can be merged—hopefully after addressing a few small comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273005318


##########
tests/integration_tests/dashboards/security/security_rbac_tests.py:
##########
@@ -191,7 +190,7 @@ def test_get_dashboard_view__user_access_with_dashboard_permission(self):
 
         request_payload = get_query_context("birth_names")
         rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
-        self.assertEqual(rv.status_code, 200)
+        self.assertEqual(rv.status_code, 403)

Review Comment:
   This test (alongside others) was was failing after the change which likely indicates that either i) RBAC were supposed to expend beyond the scope/context of the dashboard (and thus my understanding of said issue was miscontrued), or ii) was a mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273005318


##########
tests/integration_tests/dashboards/security/security_rbac_tests.py:
##########
@@ -191,7 +190,7 @@ def test_get_dashboard_view__user_access_with_dashboard_permission(self):
 
         request_payload = get_query_context("birth_names")
         rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
-        self.assertEqual(rv.status_code, 200)
+        self.assertEqual(rv.status_code, 403)

Review Comment:
   This test (alongside others) was failing after the change which likely indicates that either i) RBAC was supposed to expand beyond the scope/context of the dashboard (and thus my understanding of said issue was misconstrued), or ii) was a mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273005318


##########
tests/integration_tests/dashboards/security/security_rbac_tests.py:
##########
@@ -191,7 +190,7 @@ def test_get_dashboard_view__user_access_with_dashboard_permission(self):
 
         request_payload = get_query_context("birth_names")
         rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
-        self.assertEqual(rv.status_code, 200)
+        self.assertEqual(rv.status_code, 403)

Review Comment:
   This test (alongside others) was failing after the change which likely indicates that either i) RBAC were supposed to expend beyond the scope/context of the dashboard (and thus my understanding of said issue was misconstrued), or ii) was a mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1276528964


##########
superset/security/manager.py:
##########
@@ -1827,25 +1826,26 @@ def raise_for_access(
                 )
 
         if datasource or query_context or viz:
+            form_data = None
+
             if query_context:
                 datasource = query_context.datasource
+                form_data = query_context.form_data
             elif viz:
                 datasource = viz.datasource
+                form_data = viz.form_data
 
             assert datasource
 
-            should_check_dashboard_access = (
-                feature_flag_manager.is_feature_enabled("DASHBOARD_RBAC")
-                or self.is_guest_user()
-            )
-
             if not (
                 self.can_access_schema(datasource)
                 or self.can_access("datasource_access", datasource.perm or "")
                 or self.is_owner(datasource)
                 or (
-                    should_check_dashboard_access
-                    and self.can_access_based_on_dashboard(datasource)
+                    form_data
+                    and (dashboard_id := form_data.get("dashboardId"))
+                    and (dashboard := DashboardDAO.find_by_id(dashboard_id))
+                    and self.can_access_dashboard(dashboard)

Review Comment:
   @eschutho the logic is as follows. If you don't have explicit access to dataset you then fallback to the form-data of either the visualization or query-context to try to decipher the context. If it's in the context of a dashboard, i.e., you're viewing a chart in a dashboard, one checks whether you have access to the dashboard—per the `can_access_dashboard` method.



##########
superset/security/manager.py:
##########
@@ -1827,25 +1826,26 @@ def raise_for_access(
                 )
 
         if datasource or query_context or viz:
+            form_data = None
+
             if query_context:
                 datasource = query_context.datasource
+                form_data = query_context.form_data
             elif viz:
                 datasource = viz.datasource
+                form_data = viz.form_data
 
             assert datasource
 
-            should_check_dashboard_access = (
-                feature_flag_manager.is_feature_enabled("DASHBOARD_RBAC")
-                or self.is_guest_user()
-            )
-
             if not (
                 self.can_access_schema(datasource)
                 or self.can_access("datasource_access", datasource.perm or "")
                 or self.is_owner(datasource)
                 or (
-                    should_check_dashboard_access
-                    and self.can_access_based_on_dashboard(datasource)
+                    form_data
+                    and (dashboard_id := form_data.get("dashboardId"))
+                    and (dashboard := DashboardDAO.find_by_id(dashboard_id))
+                    and self.can_access_dashboard(dashboard)

Review Comment:
   @eschutho the logic is as follows. If you don't have explicit access to dataset you then fallback to the form-data of either the visualization or query-context to try to decipher the context. If it's in the context of a dashboard, i.e., you're viewing a chart in a dashboard, one checks whether you have access to the dashboard—per the `can_access_dashboard` method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1283780660


##########
superset/security/manager.py:
##########
@@ -1827,25 +1826,26 @@ def raise_for_access(
                 )
 
         if datasource or query_context or viz:
+            form_data = None
+
             if query_context:
                 datasource = query_context.datasource
+                form_data = query_context.form_data
             elif viz:
                 datasource = viz.datasource
+                form_data = viz.form_data
 
             assert datasource
 
-            should_check_dashboard_access = (
-                feature_flag_manager.is_feature_enabled("DASHBOARD_RBAC")
-                or self.is_guest_user()
-            )
-
             if not (
                 self.can_access_schema(datasource)
                 or self.can_access("datasource_access", datasource.perm or "")
                 or self.is_owner(datasource)
                 or (
-                    should_check_dashboard_access
-                    and self.can_access_based_on_dashboard(datasource)
+                    form_data
+                    and (dashboard_id := form_data.get("dashboardId"))
+                    and (dashboard := DashboardDAO.find_by_id(dashboard_id))
+                    and self.can_access_dashboard(dashboard)

Review Comment:
   @villebro is the logic on line #1846 not suffice, i.e., extracting the dashboard ID from the form-data (which could stem from either a legacy visualization or query-context)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] mdeshmu commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "mdeshmu (via GitHub)" <gi...@apache.org>.
mdeshmu commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1663353663

   @michael-s-molina can this be included in 3.0 ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652130308

   @john-bodley @Vitor-Avila did a fix in https://github.com/apache/superset/pull/24808 giving access to datasets that power native filters, when using Dashboard RBAC. Can we include his changes here, or would that use case already work with your changes?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652153132

   Thanks @betodealmeida for sharing @Vitor-Avila's PR. Initially I can't say whether this change will resolve said issue as it's not apparent where (and with what arguments) the `raise_for_access` method is being invoked from regarding the native filters.
   
   @Vitor-Avila would you mind using my branch to test your issue? Note assuming the approach outlined in this PR is correct (@villebro it's probably the definitive expert on this) and it doesn't address @Vitor-Avila's issue, I do sense the right solution there is make sure that the access for native filters is akin to that of dashboard charts.
   
   Personally I'm a tad worried about the `DASHBOARD_RBAC` feature flag as I don't think all the various paths have been fully flushed out. Furthermore our default security manager/policy is already somewhat of a complex web of rules which only gets worse when you add another variable (the feature flag) to the mix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Vitor-Avila commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652216735

   Yup, I confirmed the issue still exists in this branch:
   ![image](https://github.com/apache/superset/assets/96086495/35edd054-a3ad-47bd-b4a8-26d95a41bc62)
   
   @eschutho mentioned you also have a PR to re-introduce the logic from `can_access_based_on_dashboard`: https://github.com/apache/superset/pull/24804
   
   Should I try to re-create my changes on top of this modification? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on PR #24789:
URL: https://github.com/apache/superset/pull/24789#issuecomment-1652341102

   @Vitor-Avila I think we likely need to take a pause on this for now until collectively the community can agree on how the dashboard RBAC are supposed to work. Hopefully this can happen sometime next week once some of the Apache Superset committers who are well versed in this space are back online.
   
   The challenge otherwise is we could find ourselves playing whack-a-mole with trying to fix issues whilst simultaneously creating other ones. Taking a more holistic (30,000') view of problem will likely help everyone better grok the intention and thus what access controls are required.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24789: fix: Dashboard aware RBAC dataset permission

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24789:
URL: https://github.com/apache/superset/pull/24789#discussion_r1273002147


##########
tests/integration_tests/security_tests.py:
##########
@@ -1674,24 +1677,64 @@ def test_raise_for_access_table(self, mock_can_access):
         with self.assertRaises(SupersetSecurityException):
             security_manager.raise_for_access(database=database, table=table)
 
+    @patch("superset.security.manager.g")
     @patch("superset.security.SupersetSecurityManager.is_owner")
     @patch("superset.security.SupersetSecurityManager.can_access")
     @patch("superset.security.SupersetSecurityManager.can_access_schema")
     def test_raise_for_access_viz(
-        self, mock_can_access_schema, mock_can_access, mock_is_owner
+        self, mock_can_access_schema, mock_can_access, mock_is_owner, mock_g
     ):
         test_viz = viz.TimeTableViz(self.get_datasource_mock(), form_data={})
 
         mock_can_access_schema.return_value = True
         security_manager.raise_for_access(viz=test_viz)
 
+        mock_g.user = security_manager.find_user("gamma")
         mock_can_access.return_value = False
         mock_can_access_schema.return_value = False
         mock_is_owner.return_value = False
 
         with self.assertRaises(SupersetSecurityException):
             security_manager.raise_for_access(viz=test_viz)
 
+    @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")

Review Comment:
   I'm not sure this is needed, i.e., `test_get_dashboard_view__user_access_with_dashboard_permission` might be suffice.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org