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 Exception FabAirflowSecurityManagerOverride #36437

Closed
wants to merge 1 commit into from
Closed

Fix Exception FabAirflowSecurityManagerOverride #36437

wants to merge 1 commit into from

Conversation

maiconkkl
Copy link

related: #36432
The exception raised Your CUSTOM_SECURITY_MANAGER must extend FabAirflowSecurityManagerOverride, not FAB's own security manager.
My English is not good, so I ask you to be patient.
The error happens when extending the FabAirflow SecurityManagerOverride class to create custom authentication

Copy link

boring-cyborg bot commented Dec 26, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

Copy link
Collaborator

@dirrao dirrao left a comment

Choose a reason for hiding this comment

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

LGTM

@potiuk
Copy link
Member

potiuk commented Dec 26, 2023

I think the intention here was a bit different and I'd wait for @vincbeck to come back from holidays to merge this one. There were a few changes to the structure of the Auth Manager class and @vincbeck has PRs with doc in progress to describe them better - so I'd keep it around till he is back.

@maiconkkl
Copy link
Author

maiconkkl commented Dec 26, 2023

I think the intention here was a bit different and I'd wait for @vincbeck to come back from holidays to merge this one. There were a few changes to the structure of the Auth Manager class and @vincbeck has PRs with doc in progress to describe them better - so I'd keep it around till he is back.

I haven't seen these PRs, however they are intended for 2.8.* ?

I saw that there were some changes in main, but I believe it would be for a new version, maybe 2.9
Exemple #36232

@potiuk
Copy link
Member

potiuk commented Dec 26, 2023

Not really. We are cherry-picking some changes from main to be released in 2.8.* - these are bug-fixes and doc updates mostly - so.I'd say this (and doc changes) should go to 2.8.1. it is about more complicated because in main we already moved FAB to separate provider, which will make cherry-picking a bit more complex - that's why as well I think we should do any fixes here while @vincbeck is around to make sure we all make sure we are doing the right things.

@DjVinnii
Copy link
Contributor

I'm also running into the related issue, so a fix will be great as it is now blocking us to upgrade to Airflow 2.8. To me the proposed fix should do the trick as the raised error indicates the check is inverted.

@potiuk
Copy link
Member

potiuk commented Dec 27, 2023

I'm also running into the related issue, so a fix will be great as it is now blocking us to upgrade to Airflow 2.8. To me the proposed fix should do the trick as the raised error indicates the check is inverted.

It will stil have to be released in 2.8.1 and it will take some time. So feel free to apply the patch for now in your version - this is the fastest way you can get it fixed for you now.

@potiuk
Copy link
Member

potiuk commented Dec 27, 2023

This is a beauty of Open-Source software. You can ALWAYS patch things while waiting for a more complete ifx. And rushing fixes without having a full knowledge is often bad idea. Go slow to move fast.

@potiuk potiuk added this to the Airflow 2.8.1 milestone Dec 27, 2023
Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

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

I am against this change.

What is the value of SECURITY_MANAGER_CLASS in your scenario? There is something weird because this check was already there before we migrated the code to fab provider, so it should not be a breaking change. We want to make sure whatever class you defined in SECURITY_MANAGER_CLASS inherits from AirflowSecurityManager. Again, this check was there before so there must be something off somewhere.

@maiconkkl
Copy link
Author

maiconkkl commented Jan 2, 2024

I am against this change.

What is the value of SECURITY_MANAGER_CLASS in your scenario? There is something weird because this check was already there before we migrated the code to fab provider, so it should not be a breaking change. We want to make sure whatever class you defined in SECURITY_MANAGER_CLASS inherits from AirflowSecurityManager. Again, this check was there before so there must be something off somewhere.

Hello vincbeck, how are you? Happy New Year!!!

When trying to extend AirflowSecurityManager I receive a DeprecationWarning with the following message
"Call to deprecated class AirflowSecurityManager. (If you want to override the security manager, you should inherit from airflow.auth.managers.fab.security_manager.override.FabAirflowSecurityManagerOverride instead)"

And when trying to extend FabAirflowSecurityManagerOverride I receive an Exception with the following message
"Your CUSTOM_SECURITY_MANAGER must extend FabAirflowSecurityManagerOverride, not FAB's own security manager."

Interpreting what the warnings say, I understand that the AirflowSecurityManager class is becoming obsolete and needs to extend the FabAirflowSecurityManagerOverride class and my change proposes exactly that

class Cav4Authorizer(FabAirflowSecurityManagerOverride):
    def auth_user_db(self, username: str, password: str):
        """
        Authenticate user, auth db style.

        :param username:
            The username or registered email address
        :param password:
            The password, will be tested against hashed password on db
        """
        if username is None or username == "":
            return None

@vincbeck
Copy link
Contributor

vincbeck commented Jan 2, 2024

Happy new year too @maiconkkl. Thanks for all the details and indeed there is a bug. This is related to #36343 as well. I just figured out the bug, let me create a PR for it. I'll explain the details there

@vincbeck
Copy link
Contributor

vincbeck commented Jan 2, 2024

See #36538

@vincbeck
Copy link
Contributor

vincbeck commented Jan 2, 2024

@maiconkkl if you could pull the changes of this PR locally and do some testing on your end, that would be very appreciated :)

@maiconkkl
Copy link
Author

@maiconkkl if you could pull the changes of this PR locally and do some testing on your end, that would be very appreciated :)

I already tested it and it works well for me

@vincbeck
Copy link
Contributor

vincbeck commented Jan 2, 2024

@maiconkkl if you could pull the changes of this PR locally and do some testing on your end, that would be very appreciated :)

I already tested it and it works well for me

Thank you!

@maiconkkl maiconkkl closed this Jan 2, 2024
@maiconkkl maiconkkl deleted the 2.8.0_new branch January 2, 2024 19:10
@ephraimbuddy ephraimbuddy removed this from the Airflow 2.8.1 milestone Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants