vincbeck commented on code in PR #33213: URL: https://github.com/apache/airflow/pull/33213#discussion_r1305941953
########## airflow/auth/managers/models/resource_details.py: ########## @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +from dataclasses import dataclass + + +@dataclass +class ResourceDetails: + """ + Represents the details of a resource. + + All fields must be optional. These details can be used in authorization decision. + """ + + id: str | None = None Review Comment: I agree with **ALMOST** everything. At the end, I definitely agree with you we might end up having multiple private `_is_authorized_dag` ... There is one thing I dont really like with that though. We can certainly say that the resource attribute `id` is something common to all or the vast majority of resource types in Airflow. Example: when a user wants to modify a Variable `test-variable`, we definitely should call `is_authorized` with the variable ID `test-variable`. And so on for all resource types (there might be some exceptions). FAB auth manager might handle only the DAG ids but I dont think we should have this limitation in all auth managers. As a user/admin I'd like to be able to specify permissions by resource ID across all resource types. That would mean then having an `is_authorized` per resource type, which I think ... is massive. So I have a proposal: why dont we add an optional parameter `resource_id` to the `is_authorized` method and we drop `resource_details`. This method would be used for any resource type with no additional details. For resources where additional details are needed when calling `is_authorized`, we would expose individual `is_authorized_` API with associated `resource_details` (basically, your proposal) without the resource ID since it is already provided as individual parameter. WDYT? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
