You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/12/25 08:51:34 UTC

[GitHub] [superset] villebro opened a new pull request, #22526: feat(rbac): add customizable related filters

villebro opened a new pull request, #22526:
URL: https://github.com/apache/superset/pull/22526

   ### SUMMARY
   This is a continuation of #21515, which made it possible to exclude specific users from dropdown lists, to make it possible to add arbitrary filter conditions to both the user and role dropdowns. The primary reason for this is to be able to restrict the available roles in the Dashboard role dropdown when using `DASHBOARD_RBAC`, as users may unintentionally give too wide access to dashboards by sharing with a too generic role. Similarly, there may be a need to restrict to whom a user should be able to give ownership of an object.
   
   To demonstrate, by adding the following to `superset_config.py`, the owners dropdown now only contains the entry `admin`, and the roles dropdown only contains entries containing the letter "a":
   
   ```python
   def role_filter(query):
       from superset import security_manager
   
       role_model = security_manager.role_model
       filters = [role_model.name.like("A%")]
       return query.filter(or_(*filters))
   
   
   def user_filter(query):
       from superset import security_manager
   
       user_model = security_manager.user_model
       filters = [user_model.username == "admin"]
       return query.filter(or_(*filters))
   
   
   EXTRA_RELATED_QUERY_FILTERS = {
       "role": role_filter,
       "user": user_filter,
   }
   ```
   
   Now users only displays "Admin":
   
   <img width="887" alt="image" src="https://user-images.githubusercontent.com/33317356/209462025-fb9c46be-b772-461d-bf8b-473aeeda0760.png">
   
   Similarly roles only contains "Admin" and "Alpha":
   
   <img width="884" alt="image" src="https://user-images.githubusercontent.com/33317356/209462080-af7f9786-fb74-41e9-8906-052fc8e148e9.png">
   
   ### TESTING INSTRUCTIONS
   1. Add the above to `superset_config.py`
   2. Go to dashboard, chart and dataset CRUD views and ensure that the owners and roles dropdowns only contains the expected values.
   
   ### 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] codecov[bot] commented on pull request #22526: feat(rbac): add customizable related filters

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #22526:
URL: https://github.com/apache/superset/pull/22526#issuecomment-1364647729

   # [Codecov](https://codecov.io/gh/apache/superset/pull/22526?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#22526](https://codecov.io/gh/apache/superset/pull/22526?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0b604dd) into [master](https://codecov.io/gh/apache/superset/commit/b6d39d194c90dbbf0050bb3d32d2e1a513dfc0a6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b6d39d1) will **decrease** coverage by `11.27%`.
   > The diff coverage is `55.00%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #22526       +/-   ##
   ===========================================
   - Coverage   66.91%   55.64%   -11.28%     
   ===========================================
     Files        1851     1851               
     Lines       70715    70731       +16     
     Branches     7766     7766               
   ===========================================
   - Hits        47320    39359     -7961     
   - Misses      21373    29350     +7977     
     Partials     2022     2022               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `52.36% <55.00%> (+<0.01%)` | :arrow_up: |
   | python | `57.61% <55.00%> (-23.67%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `51.19% <55.00%> (+<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=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/22526?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/views/filters.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdmlld3MvZmlsdGVycy5weQ==) | `61.76% <30.76%> (-38.24%)` | :arrow_down: |
   | [superset/config.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29uZmlnLnB5) | `91.04% <100.00%> (-0.45%)` | :arrow_down: |
   | [superset/dashboards/api.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9hcGkucHk=) | `51.14% <100.00%> (-41.43%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/tags/core.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdGFncy9jb3JlLnB5) | `4.54% <0.00%> (-95.46%)` | :arrow_down: |
   | [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-90.91%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-87.88%)` | :arrow_down: |
   | [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-84.00%)` | :arrow_down: |
   | [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
   | ... and [285 more](https://codecov.io/gh/apache/superset/pull/22526/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :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=The+Apache+Software+Foundation)
   


-- 
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] EugeneTorap commented on pull request #22526: feat(rbac): add customizable related filters

Posted by GitBox <gi...@apache.org>.
EugeneTorap commented on PR #22526:
URL: https://github.com/apache/superset/pull/22526#issuecomment-1365105633

   LGTM! Thanks for this PR


-- 
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 merged pull request #22526: feat(rbac): add customizable related filters

Posted by GitBox <gi...@apache.org>.
villebro merged PR #22526:
URL: https://github.com/apache/superset/pull/22526


-- 
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