You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/10/01 03:36:03 UTC

[GitHub] [airflow] feng-tao commented on a change in pull request #6219: Dags filter by owner in RBAC

feng-tao commented on a change in pull request #6219: Dags filter by owner in RBAC
URL: https://github.com/apache/airflow/pull/6219#discussion_r329867789
 
 

 ##########
 File path: airflow/www_rbac/views.py
 ##########
 @@ -229,11 +229,17 @@ def get_int_arg(value, default=0):
             hide_paused = False
         else:
             hide_paused = hide_paused_dags_by_default
-
-        # read orm_dags from the db
-        query = session.query(DM).filter(
-            ~DM.is_subdag, DM.is_active
-        )
+        current_user = appbuilder.sm.get_user()
+        roles = {role.name for role in current_user.roles}
+        # read orm_dags from the db filter by owner, if the user is not admin
+        if ({'Admin'} & roles):
+            query = session.query(DM).filter(
+                ~DM.is_subdag, DM.is_active
+            )
+        else:
+            query = session.query(DM).filter(
+                ~DM.is_subdag, DM.is_active, DM.owners == current_user.username
 
 Review comment:
   FYI, owners is a list.

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


With regards,
Apache Git Services