Skip to content

Clarify / standardize Airflow API permissions definitions #51971

@zach-overflow

Description

@zach-overflow

What do you see as an issue?

(preamble): I'm happy to help out with any doc work or code refactors to address this issue; but, I'm raising this issue partly because I myself do not know the correct answer to the details which I think need to be added to the auth manager / security docs.

Description

This issue pertains to the core auth manager docs (as of Airflow version 3.0.2). While the auth manager doc briefly covers the methods to override when implementing a custom Auth manager, the docs do not clarify any of the following details, which I believe are crucial for a proper implementation of a custom auth manager:

  1. What role do the resource identifiers in airflow.security.permissions play in the auth manager?
  2. How do the airflow.api_fastapi.auth.managers.models.resource_details class definitions relate to similarly named identifiers in airflow.security.permission?
  3. Likewise, the docs do not clarify the implicit hierarchy of resources/permissioning in the DagAccessEntity.
  4. Whether the FAB auth manager is slated for deprecation in the near future.
  5. Which API-action + resource combinations are possible or not, especially as it relates to DAG sub-entities. (I was only able to understand some of these expected action-resource combinations by digging through the various files under airflow.api_fastapi.core_api.routes.public, but it feels risky to base my assumptions on code which may not be part of the public interface)

Why is this an issue?

  1. If the auth manager docs explained these concepts thoroughly, it would benefit both Airflow end-users as well as Airflow core contributors seeking to help out with the remaining auth manager implementations (i.e. KeyCloak, AWS, etc).
  2. This also could present unintended security risks if the various authorization-related resource entities remain inconsistently defined as dataclasses, enums, or string constants in various locations, without any documentation recommending the use of one definition over the other.
  3. It seems that in general, I've not been the only one who has found the current auth manager docs in need of clarifications, such as in these 2 recent threads: Airflow not using custom API authentication/auth_backends #51362 API Authentication in Airflow 3.0.0 with FAB Provider #50684 . I believe the omissions I listed may help alleviate some (albeit not all of the common sticking points raised in those threads).

Solving the problem

  1. Clarify what resource definitions users should rely on for their auth manager implementations:
    • Should people use the constants in airflow.security.permissions, if not, why / what is that module's intended use?
    • What exactly do the various id attributes refer to in the classes defined in airflow.api_fastapi.auth.models.resource_details passed into the auth manager's is_authorized_* methods? How should user's rely on those fields, and what is the recommended approach for when those resource details arguments are None?
  2. Maybe add a diagram for the expected resource hierarchies in the API permissions models, or at least describe the potential interactions between the various is_authorized_* methods. For example, it would be nice to have a reference for the expected potential interactions between is_authorized_dag and is_authorized_backfill which is implicitly defined here.

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions