-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
AIP-84 | Add Auth for Dags #47062
AIP-84 | Add Auth for Dags #47062
Conversation
Hi @pierrejeambrun, Here is a draft for the first entity that introduces authentication and permissions. I want to ensure consistency across other entities and would appreciate your advice on the following changes:
Looking forward to your thoughts! |
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.
Great start 🎉
Is adding _should_response_401 test cases for each router sufficient?
I think so yes.
36346db
to
625cda9
Compare
625cda9
to
5525f2a
Compare
After discussing with @rawwar offline, we determined that the previous test failure with
After further discussion, by setting
|
The rest of CI failures are caused by some side effect of auth_manage with FastAPI app, but I still can't figure out what is the root cause: e.g.
If I remove the @pytest.fixture
def test_client():
with conf_vars(
{
(
"core",
"auth_manager",
): "airflow.auth.managers.simple.simple_auth_manager.SimpleAuthManager",
}
):
yield TestClient(create_app()) Only |
10f76c6
to
6a10d9e
Compare
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.
Looks like this is the first one that we need to merge to unblock other permissions PR.
Do you need help fixing the CI ?
edit: Let me take a look.
Indeed, this is the first PR for permissions.
Yes, I need more thought for the CI errors, thanks! As I mentioned in #47062 (comment) explicitly commit the session can resolve, but I think that is kind of workaround way to solve it. I haven't come out other idea to solving it. |
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.
I took a look at the failing TestPostAssetMaterialize
for test_should_respond_200
.
Indeed we are missing a commit there in the create_dags
fixture.dag_maker
will just not commit the change I believe if the session is provided from the caller.
I don't get why it was working before, maybe changing the client fixture to a context manager updated the pytest fixture resolution order, in such a way that we were lucky before, a fixture with a commit
appeared later than the create_dags
one and was hidding the issue ? I don't know.
Basically it's the same for configure_git_connection_for_dag_bundle
fixture. Theoritically nobody is committing the new connection. If there are no other fixtures called or init code, we will end up without the connection in the db. (and locking error on sqlite).
Also test_should_respond_200_with_versions
(reason for another failed test). In the loop make_dag_with_multiple_versions
the last iteration will be missing the commit, dag.sync_to_db()
is acting like it, you can just move it to the end of the loop I think to achieve that.
I guess other cases are similar to that.
Basically fixture creating db objects should commit. (or not commit if the helper code they call do the commit for them)
I found this piece of code in the dag_maker:
|
We'll merge #47136 first, you can rebase then it will fix your CI issues. |
I think that is the only way to illustrate this wired error, thanks for the explanation !
Thanks to point out, so that we should commit explicitly when using Maybe, the test I wrote with before utilize |
c7410a6
to
8c8ded1
Compare
8c8ded1
to
4e1b9d9
Compare
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.
Nice, this needs a rebase I think.
4e1b9d9
to
cc9676b
Compare
Just rebased, thanks! There's still an open discussion regarding SimpleAuthManager that needs confirmation: #47062 (comment). |
5d53a39
to
e8d643b
Compare
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.
Needs rebase + conflict soliving.
Nice, just a few suggestions
f2c5973
to
eb6ac7c
Compare
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.
LGTM just a few nits (non blocking)
Fix mypy error
eb6ac7c
to
807dd89
Compare
Thanks @pierrejeambrun , just resolved and rebased. |
* AIP-84 | Add Auth for Dag * Refactor conftest for api_fastapi and test_dags * fixup! AIP-84 | Add Auth for Dag * Add unauthorized 403 test cases * Remove PATCH in requires_access * Fix unauthorized_test_client, requires_access_dag * Add EditableDagsFilterDep, ReadableDagsFilterDep * Add permitted_dag_filter for dags API * Fix test_security * Add OrmFilterClause Fix mypy error * fixup! Add OrmFilterClause
related: #42360
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.