-
Notifications
You must be signed in to change notification settings - Fork 17.6k
AWS auth manager: implement all is_authorized_* methods (but is_authorized_dag)
#35928
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,13 @@ def is_authorized_configuration( | |
| details: ConfigurationDetails | None = None, | ||
| user: BaseUser | None = None, | ||
| ) -> bool: | ||
| return self.is_logged_in() | ||
| config_section = details.section if details else None | ||
| return self.avp_facade.is_authorized( | ||
| method=method, | ||
| entity_type=AvpEntities.CONFIGURATION, | ||
| user=user or self.get_user(), | ||
| entity_id=config_section, | ||
| ) | ||
|
|
||
| def is_authorized_cluster_activity(self, *, method: ResourceMethod, user: BaseUser | None = None) -> bool: | ||
| return self.is_logged_in() | ||
|
|
@@ -103,7 +109,13 @@ def is_authorized_connection( | |
| details: ConnectionDetails | None = None, | ||
| user: BaseUser | None = None, | ||
| ) -> bool: | ||
| return self.is_logged_in() | ||
| connection_id = details.conn_id if details else None | ||
| return self.avp_facade.is_authorized( | ||
| method=method, | ||
| entity_type=AvpEntities.CONNECTION, | ||
| user=user or self.get_user(), | ||
| entity_id=connection_id, | ||
| ) | ||
|
|
||
| def is_authorized_dag( | ||
| self, | ||
|
|
@@ -118,12 +130,24 @@ def is_authorized_dag( | |
| def is_authorized_dataset( | ||
| self, *, method: ResourceMethod, details: DatasetDetails | None = None, user: BaseUser | None = None | ||
| ) -> bool: | ||
| return self.is_logged_in() | ||
| dataset_uri = details.uri if details else None | ||
| return self.avp_facade.is_authorized( | ||
| method=method, | ||
| entity_type=AvpEntities.DATASET, | ||
| user=user or self.get_user(), | ||
| entity_id=dataset_uri, | ||
| ) | ||
|
|
||
| def is_authorized_pool( | ||
| self, *, method: ResourceMethod, details: PoolDetails | None = None, user: BaseUser | None = None | ||
| ) -> bool: | ||
| return self.is_logged_in() | ||
| pool_name = details.name if details else None | ||
| return self.avp_facade.is_authorized( | ||
| method=method, | ||
| entity_type=AvpEntities.POOL, | ||
| user=user or self.get_user(), | ||
| entity_id=pool_name, | ||
| ) | ||
|
|
||
| def is_authorized_variable( | ||
| self, *, method: ResourceMethod, details: VariableDetails | None = None, user: BaseUser | None = None | ||
|
|
@@ -142,7 +166,12 @@ def is_authorized_view( | |
| access_view: AccessView, | ||
| user: BaseUser | None = None, | ||
| ) -> bool: | ||
| return self.is_logged_in() | ||
| return self.avp_facade.is_authorized( | ||
| method="GET", | ||
| entity_type=AvpEntities.VIEW, | ||
| user=user or self.get_user(), | ||
| entity_id=access_view.value, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we have a check for this value and default to None like the others?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this one required but not the others? I think maybe the answer to my other comment might answer this as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other are optional because when you do authorization request, you might not need to specify a resource ID. Example: "Does the user have permission to create a Variable". There is no resource ID here. Here this is not really a resource ID but more a specific of which view the user is trying to access. We must specify which view the user is trying to access |
||
| ) | ||
|
|
||
| def get_url_login(self, **kwargs) -> str: | ||
| return url_for("AwsAuthManagerAuthenticationViews.login") | ||
|
|
||
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.
If the section is None then is this basically checking if the user is authorized for all/any config?
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.
It is checking if the user is authorized for all config. This is a really good question and this has been bugging me for a while. Does
auth_manager.is_authorized_variable("GET")means:I decided to go with the former because this is actually how Amazon Verified Permissions work. You cannot ask AVP to check whether the user is authorized to access ANY variable (or any type of resource type).
But this has some implications. Example: As a user I am allowed to access only variables starting with "tmp_" (thus not all variables), thus I wont be allowed to see the list of variables (or even the menu). The reason why the user would not be able to see the menu "Variables" or the list of variables is because to display those, we check whether the user has permissions to read all variables. So this is not perfect either (and we might change it) but I guess we can leave that interrogation for later/another PR
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.
But I dont know if this is something we should thing about because Airflow is not ready for such use cases. The views (this is the first time that comes to my mind) are displaying all resources from database without filtering (we could change that of course)
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.
@shubham22. Related to the discussion we had
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.
Good discussion, it sounds like we'll likely merge this either way so I'll approve since the code looks good otherwise. But please keep the discussion going to see where we net out on this topic.