-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix inheritance chain in security manager #33901
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
Conversation
vincbeck
left a comment
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.
The whole goal of this change was not to make FabAirflowSecurityManagerOverride inherit from AirflowSecurityManager?
Oh now I might understand why you made inherited Db and Oauth module from AirflowSecurityManager. I guess you wanted a more vertical hierarchy. The idea of modules I introduced in FabAirflowSecurityManagerOverride was to avoid to build a big monster class very hard to maintain, so I split it in multiple modules. To me, making these modules inherited from AirflowSecurityManager does not really make sense.
I would:
- Remove dependency between the modules and
AirflowSecurityManager - Add dependency between
FabAirflowSecurityManagerOverrideandAirflowSecurityManager
WDYT?
BTW, I'm wondering if this isn't causing more harm than good. |
If you think this is better without these modules, let's go then |
| if TYPE_CHECKING: | ||
| from airflow.api_connexion.types import APIResponse, UpdateMask | ||
| from airflow.www.security import AirflowSecurityManager | ||
| from airflow.www.security_manager import AirflowSecurityManagerV2 |
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.
Since on the long term we will deprecate AirflowSecurityManager in favor of AirflowSecurityManagerV2 I am wondering if AirflowSecurityManagerV2 is a good name since this name will stay. Should we keep the name AirflowSecurityManager? It can confusing but we can assume this is only temporary? Or should we come up with another name? SimplifiedAirflowSecurityManager? I dont like it either xD.
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.
temporary things still stay around for a pretty long time to give users time to migrate...
Idk, I'm open to suggestions, but we can always rename it once we remove the old one.
|
I need to twist my head around it :). Will take a look tomorrow . |
|
We should double check it resolves: #34107 |
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
| from airflow.www.fab_security.sqla.manager import SecurityManager | ||
| from airflow.www.utils import CustomSQLAInterface | ||
|
|
||
| EXISTING_ROLES = { |
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.
@vandonr-amz @vincbeck are we considering removing EXISTING_ROLES from here a breaking change or I'm missing something here?
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.
Why would that be a breaking change? In which case user code would use this constant? The only use case I can think of is, if the user provide its own security manager and inside this security manager, they use this constant. But if we want to avoid such things ... every change will be breaking change and doing any change in security managers will be almost impossible.
Or maybe you had something else in mind?
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.
Why would that be a breaking change
yes, it breaking change because I import this constant from airflow.www.security import EXISTING_ROLES in my security manager and after this changes my code will break.
But if we want to avoid such things ... every change will be breaking change and doing
from airflow.www.security import * import path was very important for the implementing custom security manager and I feel it would be natural for many people to import EXISTING_ROLES if they need this rather than redefine so removing this suddenly is not good and may impact other users. I understand that maintaining backward compatibility for constant type this is painful but still, I would like to keep this maybe we can remove it when we decide to remove airflow.www.security.py
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 see ... I'll try to think about a solution. We might have to keep whatever is static (constants, variables, functions) in these files then ... Which I really dont like ... But it seems we do not have much choice if we want to be backward compatible with users bringing their own security managers. I wish this feature did not exist xD.
But anyway, thanks for the feedback. I'll probably create a PR to fix that and will tag you on 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.
Thanks @vincbeck
In #33901 this was moved to a new file and mistakenly changed to flask_session. It's not clear to me why this didn't cause errors, but it was highlighted in my editor as an invalid type 🤷
…pache#44962) In apache#33901 this was moved to a new file and mistakenly changed to flask_session. It's not clear to me why this didn't cause errors, but it was highlighted in my editor as an invalid type 🤷
ℹ️ the diff is big because I re-unified the various FAB security managers in one class. See #33901 (comment)
There is currently a weird situation with the security managers, where the
AirflowSecurityManager, which is supposed to be the more generic construct, inherits fromFabAirflowSecurityManagerOverride, supposed to be the more specific one. Because of this,FabAirflowSecurityManagerOverridedoesn't bear well its name, because it cannot override anything fromAirflowSecurityManagersince it sits lower on the inheritance tree.This was done initially to be able to extend functionalities of the Security Manager, while retaining an existing feature which was that users could plug their own security manager inheriting from
AirflowSecurityManager(so we couldn't squeeze the FAB one in between because that'd be a breaking change).The solution I used here is to have an empty shell stay where the
AirflowSecurityManagerwas, just to maintain back-compatibility. That one inherits from FAB Security Manager, which can now sit below the actualAirflowSecurityManager.This means that users can only override the FAB security manager and not other auth provider's SM but that's ok because this feature is pretty much rendered obsolete by AIP-56. See #33690 (comment)
Joining some class diagrams to help understanding.
Arrows read as "is inherited/implemented by".
current situation:

after:

I had to make the
ApplessAirflowSecurityManagerinherit from the "FAB" one instead of the generic airflow SM because it had some dependencies there. It's not ideal, and not what we want in a final state, but for now we just want a state that closer to it.We'll sort that dependency later on.