airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] XD-DENG commented on a change in pull request #6199: [AIRFLOW-5562] Skip grant single DAG permissions for Admin role.
Date Fri, 27 Sep 2019 16:13:21 GMT
XD-DENG commented on a change in pull request #6199: [AIRFLOW-5562] Skip grant single DAG permissions
for Admin role.
URL: https://github.com/apache/airflow/pull/6199#discussion_r329148271
 
 

 ##########
 File path: airflow/www/security.py
 ##########
 @@ -453,12 +453,19 @@ def merge_pv(perm, view_menu):
 
     def update_admin_perm_view(self):
         """
-        Admin should have all the permission-views.
+        Admin should have all the permission-views, except the dag views.
+        because Admin have already have all_dags permission.
         Add the missing ones to the table for admin.
 
         :return: None.
         """
-        pvms = self.get_session.query(sqla_models.PermissionView).all()
+        all_dag_view = self.find_view_menu('all_dags')
+        dag_perm_ids = [self.find_permission('can_dag_edit').id, self.find_permission('can_dag_read').id]
+        pvms = self.get_session.query(sqla_models.PermissionView).filter(~and_(
+            sqla_models.PermissionView.permission_id.in_(dag_perm_ids),
+            sqla_models.PermissionView.view_menu_id != all_dag_view.id)
+        ).all()
 
 Review comment:
   Why not directly use `self.find_permission_view_menu` if you are simply looking for the
`pvm` for `all_dags`?

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

Mime
View raw message