-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
DAG-level permissions set in Web UI disappear from roles on DAG sync #32839
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
Just catching up on this issue and figured I'd write out some thoughts here - We have two places to define permissions (manually via the UI/CLI and in code via I would propose making the access control for a given DAG authoritative as long as it is explicitly set. This way, if a DAG was updated, removing So we have three cases. A DAG defined like this: with DAG(
dag_id="test",
schedule="0 0 * * *",
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
access_control={'role1': {'can_read'}, 'role2': {'can_read', 'can_edit', 'can_delete'}}
) as dag: Would overwrite any existing dag-level permissions for this DAG, ensuring that the roles listed here are the only ones with permissions specific to this DAG. While a DAG with explicitly empty access_contol, like this: with DAG(
dag_id="test",
schedule="0 0 * * *",
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
access_control={}
) as dag: Would explicitly clear out all DAG-level permissions for this role. While a DAG without any access_control defined: with DAG(
dag_id="test",
schedule="0 0 * * *",
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
) as dag: Would just defer to the existing DAG-level roles in the database. This presents its own hazards around dangling and stray permissions, but I think that any approach here is going to have some sort of downside. The important part is that the approach to DAG-level access is clearly-defined and well documented (neither of which is true at the moment). Thoughts? I likely missed some consideration here, but I am working on an implementation PR which I will share shortly. |
What happens to blanket roles in Scenario 2: empty access control if it is going to be authoritative and empty? Do all default rights/roles also get a block on them? Or do things like the Admin role still supercede these specific accesses? |
Good question - currently the airflow/airflow/www/security.py Lines 766 to 779 in b7df390
I think that this is a good policy, and access-controls at defined in DAG code should only pertain to DAG-level access, not airflow-wide access. So in the case of |
I think this is good and simple way of solving the problem. Thanks for looking into it |
Apache Airflow version
2.6.3
What happened
Versions: 2.6.2, 2.6.3, main
PR #30340 introduced a bug that happens whenever a DAG gets updated or a new DAG is added
Potential fix: Adding the code that was removed in PR #30340 back to
airflow/models/dagbag.py
fixes the issue. I've tried it on the current main branch using Breeze.What you think should happen instead
Permissions set in Web UI stay whenever a DAG sync happens
How to reproduce
docker-compose.yaml
:curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.6.2/docker-compose.yaml'
test_dag.py
to ./dags:docker compose up
Name: test
Permissions:
can read on DAG:test
test_dag.py
: changebash_command="echo 1"
tobash_command="echo 2"
can read on DAG:test
will be removedAnother option is to add a new dag instead of changing the existing one:
6. Add another dag to ./dags, code doesn't matter
7. Restart scheduler:
docker restart [scheduler container name]
9. Check test role's permissions:
can read on DAG:test
will be removedOperating System
Ubuntu 22.04.1 LTS
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
Docker 24.0.2
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: