Skip to content
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

Fix dag_id extraction for dag level access checks in web ui #23015

Merged

Conversation

npodewitz
Copy link
Contributor

Dag level permissions are not checked properly if a post request is sent from within the web ui (i.e. clear a task or dag run). If a user has can_read on any dag any operation that involves a post request is allowed even though the user does not have the can_write permission for this dag as far as the appropriate other permissions like edit_task_instance or edit_dag_run were granted. This is caused by the dag_id being extracted from request.args which only exists for get requests (i.e. change the status of a task). Otherwise None is used as dag_id in appbuilder.sm.check_authorization which essentially leads to ignoring the dag level access permissions.

I added two new tests for this specific issue.
While writing the tests I fixed a small issue in another test (test_success_fail_for_read_only_task_instance_access) that resulted in the test succeeding although not for the reason that is under test here.

This PR is a follow up to #21797 as discussed there and addresses the first issue.

At last let me thank you all again for your great work!

Properly extract dag_id from post form or json body for dag level access
permissions.
Added test case for dag level access.
Fixed test_success_fail_for_read_only_task_instance_access to succeed
due to the right reasons.
@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Apr 14, 2022
@potiuk potiuk requested a review from jhtimmins April 25, 2022 07:39
@potiuk potiuk added this to the Airflow 2.3.0 milestone Apr 25, 2022
@potiuk
Copy link
Member

potiuk commented Apr 25, 2022

Looks legit and simple enough to be included 2.3.0. LGTM but need somone who knows more about the UI and permissions.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but need second pair of eyes.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Apr 25, 2022
@github-actions
Copy link

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@ashb ashb merged commit dd62301 into apache:main Apr 25, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 25, 2022

Awesome work, congrats on your first merged pull request!

@jedcunningham jedcunningham added the type:bug-fix Changelog: Bug Fixes label Apr 25, 2022
@jedcunningham
Copy link
Member

Thanks @npodewitz! Congrats on your first commit 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues okay to merge It's ok to merge this PR as it does not require more tests type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants