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 2021/01/22 09:00:14 UTC

[GitHub] [superset] ktmud commented on a change in pull request #12680: Feat: dashboard access roles

ktmud commented on a change in pull request #12680:
URL: https://github.com/apache/superset/pull/12680#discussion_r562477859



##########
File path: superset/dashboards/filters.py
##########
@@ -88,6 +90,11 @@ def apply(self, query: Query, value: Any) -> Query:
                 )
             )
         )
+        roles_based_query = (
+            db.session.query(Dashboard.id)
+            .join(Dashboard.roles)
+            .filter(and_(Dashboard.published.is_(True), Role.id.in_(get_user_roles())),)

Review comment:
       I think `get_user_roles()` will return `Role` object instead of role ids.
   
   ```suggestion
               .filter(
                   and_(
                       Dashboard.published.is_(True),
                       Role.id.in_([x.id for x in get_user_roles()]),
                   ),
               )
   ```

##########
File path: superset/dashboards/filters.py
##########
@@ -74,12 +75,13 @@ def apply(self, query: Query, value: Any) -> Query:
 
         datasource_perms = security_manager.user_view_menu_names("datasource_access")
         schema_perms = security_manager.user_view_menu_names("schema_access")
-        published_dash_query = (
+        datesource_perm_query = (
             db.session.query(Dashboard.id)
             .join(Dashboard.slices)
             .filter(
                 and_(
-                    Dashboard.published == True,  # pylint: disable=singleton-comparison
+                    Dashboard.published.is_(True),
+                    ~Dashboard.roles.any(),

Review comment:
       This line is a little obscure. Maybe add a comment explaining what it does?
   
   ```suggestion
                       # has no role-based access specified
                       ~Dashboard.roles.any(),
   ```




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

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