Skip to content

Conversation

vincbeck
Copy link
Contributor

@vincbeck vincbeck commented Sep 5, 2025

Introduce the following methods in auth manager to list only resources (connections, pools and variables) the user has access to. With Fab auth manager you cannot define fine grained access on these resources (e.g. User X has access to connection test only) but with different auth managers such as Keycloak you can.

  • get_authorized_connections
  • filter_authorized_connections
  • get_authorized_pools
  • filter_authorized_pools
  • get_authorized_variables
  • filter_authorized_variables

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

:param method: the method to filter on
:param session: the session
"""
stmt = select(Connection.conn_id, Team.name).join(Team, Connection.team_id == Team.id, isouter=True)
Copy link
Member

Choose a reason for hiding this comment

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

Forgive me for not being up to date on this effort, but I'm a bit concerned this method is misleading. Connections don't just come from the db, so you are really just getting a partial list. Was that considered?

Copy link
Member

Choose a reason for hiding this comment

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

And to make it more tricky, secret backends don't even support listing connections from the backend...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries :) I agree this is confusing.

But I am interested by the connections returned by the API get_connections. This API retrieves connections only from the DB with this code:

connection_select, total_entries = paginated_select(
        statement=select(Connection),
        filters=[connection_id_pattern],
        order_by=order_by,
        offset=offset,
        limit=limit,
        session=session,
    )

    connections = session.scalars(connection_select)

So I assume the get_connections API only care about connections from the DB?

Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks! There is a small Mypy problem that needs some love

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the PR!

@vincbeck vincbeck force-pushed the vincbeck/get_authorized branch from af89fe8 to b9c5d5e Compare September 5, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API kind:documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants