-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require can_edit on DAG privileges to modify TaskInstances and DagRuns #16634
Require can_edit on DAG privileges to modify TaskInstances and DagRuns #16634
Conversation
Oh yes, this should totally be supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least this is going to need some tests to ensure that the behaviour you describe works, and continues to work :)
It feels weird to me actions that operate on DagRun and TaskInstance need edit permission on the DAG, since they don’t change things in it. |
I agree, which is why it probably doesn't have it right now, but the only way to express "you have edit on Dag X, but not Dag Y" and have that apply to TaskInstances/DagRuns that I can think of would be a change like this |
It already has quite some tests in there. |
I updated the PR today (26 June) with the following:
|
f794196
to
39c8c3a
Compare
Rebased PR to latest main and squashed commits. |
39c8c3a
to
179bf42
Compare
Rebased PR to latest main again. |
cc @jhtimmins Can you take a look at this please |
Given the SQLite CI/CD pipeline was successful, I think it's safe to say I fixed the tests that were failing. |
This was updated in Airflow 2.2.0 via apache#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give a Access Denied error.
This was updated in Airflow 2.2.0 via #16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error.
apache#16634) (cherry picked from commit f74d0ab)
apache#16634) (cherry picked from commit f74d0ab) (cherry picked from commit e9f0f90)
apache#16634) (cherry picked from commit f74d0ab) (cherry picked from commit e9f0f90)
apache#16634) (cherry picked from commit f74d0ab) (cherry picked from commit e9f0f90) (cherry picked from commit 0a4e99a)
This was updated in Airflow 2.2.0 via #16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. (cherry picked from commit 05b9f3d)
This was updated in Airflow 2.2.0 via #16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. (cherry picked from commit 05b9f3d)
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. (cherry picked from commit 05b9f3db5471e49e894e4148d8d1deb4361a9b53) GitOrigin-RevId: fab8b121c6906f62e28ea6485d8d8e493cb8b769
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
@Jorricks Thanks for putting together this PR. Just want to make sure I understand it correctly. With your PR merged, do I expect users without dag edit permission but with task instance delete permission can not delete a task instance, right? i.e. the behavior matches the documentation? Do I need any workaround like the SQLAlchemy listener you mentioned in the original post? Thanks! |
Hi @twang90, First of all, this has been merged a long time ago just before 2.1.0 if I remember correctly. |
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
This was updated in Airflow 2.2.0 via apache/airflow#16634 which restricts a user to even views the DagRuns and TI records if they don't have "edit" permissions on DAG even though it has "read" permissions. The Behaviour seems inconsistent as a User can still view those from the Graph and Tree View of the DAG. And since we have got `@action_has_dag_edit_access` on all the Actions like Delete/Clear etc the approach in this PR is better as when a user will try to perform any actions from the List Dag Run view like deleting the record it will give an Access Denied error. GitOrigin-RevId: 05b9f3db5471e49e894e4148d8d1deb4361a9b53
All permissions for modifying Task Instances or modifying Dag Runs as of today require
dag_read
permissions on the DAG and the corresponding action permission.A full overview is shown at the Access Control page of Airflow
It feels to me as in that case the whole
dag_edit
base_permission is undervalued in this case and thedag_view
base_permission gives too much actual permissions.Imagine the following setup:
This setup is currently not supported.
As a work around, on my work setup I currently implemented a SQLAlchemy listener to block update operations on TaskInstances where a user doesn't have
can_edit
privilege on this specific DAG.Therefore this PR changes the following items(copied from the link above) to require
DAGS.can_edit
where it currently saysDAGS.can_read
privileges.Currently:
Updated:
If there is interest in merging this PR, I will also make a corresponding PR on the docs side to update the page.